diff --git a/keycloak_test.groovy b/keycloak_test.groovy index acfa2b0..d85e868 100644 --- a/keycloak_test.groovy +++ b/keycloak_test.groovy @@ -10,87 +10,16 @@ pipeline { agent any environment { - // Keep as is the following two lines - PRIVATE_REGISTRY = "https://registry.curex-project.eu:443/curex-local/" - ARTIFACTORY_URL = "registry.curex-project.eu:443/curex-local/" - - HOST_IP = "116.203.166.220" - DEPLOYMENT_HOST = "${HOST_IP}:2376" - DEPLOYMENT_HOST_CREDENTIALS = "vm2-creds" - // KEA specific - APP_NAME = "KEA" - APP_ENV = "production" - APP_DEBUG = "true" APP_URL = "https://kea.curex-project.eu" + KEYCLOAK_URL = "https://keycloak-curex.gnubila.fr/auth/realms/Integration/protocol/openid-connect/token" + USER = credentials('keycloak-test-user') + PASSWORD = credentials('keycloak-test-password') - KIBANA_PORT = "5601" - GRAFANA_PORT = "3000" - - LOG_CHANNEL = "stack" - - DB_CONNECTION = "pgsql" - DB_HOST = "timescaledb" - DB_PORT = "5432" - DB_DATABASE = "kea" - DB_USERNAME = "postgres" - DB_PASSWORD = "postgres" - - BROADCAST_DRIVER = "log" - CACHE_DRIVER = "file" - QUEUE_CONNECTION = "sync" - SESSION_DRIVER = "file" - SESSION_LIFETIME = "120" - - JWT_TTL = "1440" - - ELASTICSEARCH_HOST = "elasticsearch" - ELASTICSEARCH_PORT = "9200" - ELASTICSEARCH_SCHEME = "http" - - MQTT_HOST = "mosquitto" - MQTT_PORT = "1883" - MQTT_DEBUG = "false" - MQTT_QOS = "0" - MQTT_RETAIN = "0" - - MLTD_HOST = "mltd" - MLTD_PORT = "5000" - OD_HOST = "od" - OD_PORT = "9091" - - KEYCLOAK_REALM_PUBLIC_KEY = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAg9OruW+gRnBcm4S1da+TDj7LdDXTFykExlg2z5Fx/vv4ldJf1/vCAEdSP/HZXRMq5TRefnkzVyv66COmjyPjGNB2P240HOOzBPnU5ibsu7H2betZvR+uj/y9o5T3hUpPy+Gbb02i57xoKyECy+yRtPjmF63R0rFfFBV/LdScWdnltTY7YfmRe6dRcBZG5QZ8bKTWP40QUzwG2PnJpIEi3KdYp4qDx4LvXnSvIC0Z6E59R2oialMKQtPO5Xu9Ea6fYe4guqX9zdpoC+bcvxjJ275zj+RoFVaQHhGBZDPeK4VITmXiUWkBbTGQwEVY8ZY4b62kWFwjOg9yOv47s6N7cQIDAQAB" - KEYCLOAK_LOAD_USER_FROM_DATABASE = "false" - KEYCLOAK_USER_PROVIDER_CREDENTIAL = "name" - KEYCLOAK_TOKEN_PRINCIPAL_ATTRIBUTE = "preferred_username" - KEYCLOAK_APPEND_DECODED_TOKEN = "false" - KEYCLOAK_ALLOWED_RESOURCES = "account" - - AUTH_ENABLED = "true" } stages { - stage('Checkout the source code') { - steps { - checkout scm - } - } - - - stage('Deploy Docker containers in DEV server') { - steps { - script { - docker.withServer("$DEPLOYMENT_HOST", "$DEPLOYMENT_HOST_CREDENTIALS") { - docker.withRegistry("$PRIVATE_REGISTRY" , 'artifactory') { - echo 'Deploying the specified Docker containers in DEV server' - sh 'sh deploy_hetzner.sh' - } - } - } - } - } - stage('Run tests') { steps { script { @@ -108,10 +37,7 @@ pipeline { } testName = "KEA_keycloak_success" - String keycloakURL = "https://keycloak-curex.gnubila.fr/auth/realms/Integration/protocol/openid-connect/token" - String user = credentials('keycloak-test-user') - String password = credentials('keycloak-test-password') - String token = sh(label: "KEA_keycloak_token", script: "curl -s -X POST $keycloakURL -H 'Content-Type: application/x-www-form-urlencoded' -d 'username=$user' -d 'password=$password' -d 'grant_type=password' -d 'client_id=KEA' | sed 's/.*access_token\":\"//g' | sed 's/\".*//g'", returnStdout: true) + String token = sh(label: "KEA_keycloak_token", script: "curl -s -X POST $KEYCLOAK_URL -H 'Content-Type: application/x-www-form-urlencoded' -d 'username=$USER' -d 'password=$PASSWORD' -d 'grant_type=password' -d 'client_id=KEA' | sed 's/.*access_token\":\"//g' | sed 's/\".*//g'", returnStdout: true) responseCode = sh(label: testName, script: "curl -m 10 -sLI -w '%{http_code}' -H 'Authorization: Bearer $token' -H 'Accept: application/json, text/plain, */*' $url -o /dev/null", returnStdout: true) if ( responseCode != '401' ) { error("$testName: Returned status code = $responseCode when calling $url")