From 7695d6fdb8268c4fba3745f849c1fd7202478952 Mon Sep 17 00:00:00 2001 From: George Vlahavas Date: Thu, 29 Jul 2021 14:16:07 +0300 Subject: [PATCH] Use a variable for CLIENT_ID --- keycloak_test.groovy | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/keycloak_test.groovy b/keycloak_test.groovy index 951a652..08e8049 100644 --- a/keycloak_test.groovy +++ b/keycloak_test.groovy @@ -15,6 +15,7 @@ pipeline { KEYCLOAK_URL = "https://keycloak-curex.gnubila.fr/auth/realms/Integration/protocol/openid-connect/token" USER = credentials('keycloak-test-user') PASSWORD = credentials('keycloak-test-password') + CLIENT_ID = "KEA" } @@ -36,7 +37,7 @@ pipeline { } testName = "KEA_keycloak_success" - 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) + String token = sh(label: "get_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=$CLIENT_ID' | 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 != '200' ) { error("$testName: Returned status code = $responseCode when calling $url") -- 2.2.2