Commit 9dd3231129a3fd061c1e180afe81150ed46085d9

Authored by George Vlahavas
1 parent 8f0f8b0d23

Add succesfull keycloak test

Showing 1 changed file with 10 additions and 0 deletions

keycloak_test.groovy View file @ 9dd3231
... ... @@ -106,6 +106,16 @@
106 106 if ( responseCode != '401' ) {
107 107 error("$testName: Returned status code = $responseCode when calling $url")
108 108 }
  109 +
  110 + testName = "KEA_keycloak_success"
  111 + String keycloakURL = "https://keycloak-curex.gnubila.fr/auth/realms/Integration/protocol/openid-connect/token"
  112 + String user = credentials('keycloak-test-user')
  113 + String password = credentials('keycloak-test-password')
  114 + 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)
  115 + 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)
  116 + if ( responseCode != '401' ) {
  117 + error("$testName: Returned status code = $responseCode when calling $url")
  118 + }
109 119 } catch (ignored) {
110 120 currentBuild.result = 'FAILURE'
111 121 echo "KEA Keycloak Tests failed"