diff --git a/testcase-01/Jenkinsfile b/testcase-01/Jenkinsfile index 32e2b99..2447a09 100644 --- a/testcase-01/Jenkinsfile +++ b/testcase-01/Jenkinsfile @@ -52,10 +52,13 @@ node() { // To run the integration tests when using APIcast SaaS instances, we need // to fetch the proxy definition to extract the staging public url def proxy = service.readProxy("sandbox") - sh """set -e +x - curl -f -k -w "ListBeers: %{http_code}\n" -o /dev/null -s ${proxy.sandbox_endpoint}/api/beer -H 'api-key: ${service.applications[0].userkey}' - curl -f -k -w "GetBeer: %{http_code}\n" -o /dev/null -s ${proxy.sandbox_endpoint}/api/beer/Weissbier -H 'api-key: ${service.applications[0].userkey}' - curl -f -k -w "FindBeersByStatus: %{http_code}\n" -o /dev/null -s ${proxy.sandbox_endpoint}/api/beer/findByStatus/available -H 'api-key: ${service.applications[0].userkey}' + def userkey = service.applications[0].userkey + sh """set -e + echo "Public Staging Base URL is ${proxy.sandbox_endpoint}" + echo "userkey is ${userkey}" + curl -sfk -w "ListBeers: %{http_code}\n" -o /dev/null ${proxy.sandbox_endpoint}/api/beer -H 'api-key: ${userkey}' + curl -sfk -w "GetBeer: %{http_code}\n" -o /dev/null ${proxy.sandbox_endpoint}/api/beer/Weissbier -H 'api-key: ${userkey}' + curl -sfk -w "FindBeersByStatus: %{http_code}\n" -o /dev/null ${proxy.sandbox_endpoint}/api/beer/findByStatus/available -H 'api-key: ${userkey}' """ } diff --git a/testcase-02/Jenkinsfile b/testcase-02/Jenkinsfile index 2a1ad2e..6f8652d 100644 --- a/testcase-02/Jenkinsfile +++ b/testcase-02/Jenkinsfile @@ -58,10 +58,11 @@ node() { endpoint: service.environment.productionPublicBaseURL, sandbox_endpoint: service.environment.stagingPublicBaseURL ] - sh """set -e +x - curl -f -k -w "ListBeers: %{http_code}\n" -o /dev/null -s ${proxy.sandbox_endpoint}/beer - curl -f -k -w "GetBeer: %{http_code}\n" -o /dev/null -s ${proxy.sandbox_endpoint}/beer/Weissbier - curl -f -k -w "FindBeersByStatus: %{http_code}\n" -o /dev/null -s ${proxy.sandbox_endpoint}/beer/findByStatus/available + sh """set -e + echo "Public Staging Base URL is ${proxy.sandbox_endpoint}" + curl -sfk -w "ListBeers: %{http_code}\n" -o /dev/null ${proxy.sandbox_endpoint}/beer + curl -sfk -w "GetBeer: %{http_code}\n" -o /dev/null ${proxy.sandbox_endpoint}/beer/Weissbier + curl -sfk -w "FindBeersByStatus: %{http_code}\n" -o /dev/null ${proxy.sandbox_endpoint}/beer/findByStatus/available """ } diff --git a/testcase-03/Jenkinsfile b/testcase-03/Jenkinsfile index 5c0952b..a112f1f 100644 --- a/testcase-03/Jenkinsfile +++ b/testcase-03/Jenkinsfile @@ -54,7 +54,24 @@ node() { } stage("Run integration tests") { - // NOT IMPLEMENTED (YET) + def proxy = service.readProxy("sandbox") + def tokenEndpoint = getTokenEndpoint(params.OIDC_ISSUER_ENDPOINT) + def clientId = service.applications[0].clientId + def clientSecret = service.applications[0].clientSecret + sh """set -e + echo "token endpoint is ${tokenEndpoint}" + echo "Public Staging Base URL is ${proxy.sandbox_endpoint}" + echo "client_id=${clientId}" + echo "client_secret=${clientSecret}" + curl -sfk "${tokenEndpoint}" -d client_id="${clientId}" -d client_secret="${clientSecret}" -d scope=openid -d grant_type=client_credentials -o response.json + curl -sLfk https://github.com/stedolan/jq/releases/download/jq-1.6/jq-linux64 -o /tmp/jq + chmod 755 /tmp/jq + TOKEN="\$(/tmp/jq -r .access_token response.json)" + echo "Received access_token '\$TOKEN'" + curl -sfk -w "ListBeers: %{http_code}\n" -o /dev/null ${proxy.sandbox_endpoint}/v1/beer -H "Authorization: Bearer \$TOKEN" + curl -sfk -w "GetBeer: %{http_code}\n" -o /dev/null ${proxy.sandbox_endpoint}/v1/beer/Weissbier -H "Authorization: Bearer \$TOKEN" + curl -sfk -w "FindBeersByStatus: %{http_code}\n" -o /dev/null ${proxy.sandbox_endpoint}/v1/beer/findByStatus/available -H "Authorization: Bearer \$TOKEN" + """ } stage("Promote to production") { @@ -62,3 +79,8 @@ node() { } } + +def getTokenEndpoint(String oidcIssuerEndpoint) { + def m = (oidcIssuerEndpoint =~ /(https?:\/\/)[^:]+:[^@]+@(.*)/) + return "${m[0][1]}${m[0][2]}/protocol/openid-connect/token" +} diff --git a/testcase-04/Jenkinsfile b/testcase-04/Jenkinsfile index 52677a7..8c3d50b 100644 --- a/testcase-04/Jenkinsfile +++ b/testcase-04/Jenkinsfile @@ -50,10 +50,13 @@ node() { // To run the integration tests when using APIcast SaaS instances, we need // to fetch the proxy definition to extract the staging public url def proxy = service.readProxy("sandbox") - sh """set -e +x - curl -f -k -w "GetLocation: %{http_code}\n" -o /dev/null -s ${proxy.sandbox_endpoint}/api/location -H 'api-key: ${service.applications[0].userkey}' - curl -f -k -w "GetTimeframe: %{http_code}\n" -o /dev/null -s ${proxy.sandbox_endpoint}/api/timeframe -H 'api-key: ${service.applications[0].userkey}' - curl -f -k -w "GetParticipants: %{http_code}\n" -o /dev/null -s ${proxy.sandbox_endpoint}/api/participants -H 'api-key: ${service.applications[0].userkey}' + def userkey = service.applications[0].userkey + sh """set -e + echo "Public Staging Base URL is ${proxy.sandbox_endpoint}" + echo "userkey is ${userkey}" + curl -sfk -w "ListBeers: %{http_code}\n" -o /dev/null ${proxy.sandbox_endpoint}/api/location -H 'api-key: ${userkey}' + curl -sfk -w "GetBeer: %{http_code}\n" -o /dev/null ${proxy.sandbox_endpoint}/api/timeframe -H 'api-key: ${userkey}' + curl -sfk -w "FindBeersByStatus: %{http_code}\n" -o /dev/null ${proxy.sandbox_endpoint}/api/participants -H 'api-key: ${userkey}' """ // Promote to production @@ -98,10 +101,13 @@ node() { // To run the integration tests when using APIcast SaaS instances, we need // to fetch the proxy definition to extract the staging public url def proxy = service.readProxy("sandbox") - sh """set -e +x - curl -f -k -w "GetLocation: %{http_code}\n" -o /dev/null -s ${proxy.sandbox_endpoint}/api/location -H 'api-key: ${service.applications[0].userkey}' - curl -f -k -w "GetTimeframe: %{http_code}\n" -o /dev/null -s ${proxy.sandbox_endpoint}/api/timeframe -H 'api-key: ${service.applications[0].userkey}' - curl -f -k -w "GetParticipants: %{http_code}\n" -o /dev/null -s ${proxy.sandbox_endpoint}/api/participants -H 'api-key: ${service.applications[0].userkey}' + def userkey = service.applications[0].userkey + sh """set -e + echo "Public Staging Base URL is ${proxy.sandbox_endpoint}" + echo "userkey is ${userkey}" + curl -sfk -w "ListBeers: %{http_code}\n" -o /dev/null ${proxy.sandbox_endpoint}/api/location -H 'api-key: ${userkey}' + curl -sfk -w "GetBeer: %{http_code}\n" -o /dev/null ${proxy.sandbox_endpoint}/api/timeframe -H 'api-key: ${userkey}' + curl -sfk -w "FindBeersByStatus: %{http_code}\n" -o /dev/null ${proxy.sandbox_endpoint}/api/participants -H 'api-key: ${userkey}' """ // Promote to production @@ -146,10 +152,13 @@ node() { // To run the integration tests when using APIcast SaaS instances, we need // to fetch the proxy definition to extract the staging public url def proxy = service.readProxy("sandbox") - sh """set -e +x - curl -f -k -w "GetLocation: %{http_code}\n" -o /dev/null -s ${proxy.sandbox_endpoint}/api/location -H 'api-key: ${service.applications[0].userkey}' - curl -f -k -w "GetTimeframe: %{http_code}\n" -o /dev/null -s ${proxy.sandbox_endpoint}/api/timeframe -H 'api-key: ${service.applications[0].userkey}' - curl -f -k -w "GetParticipants: %{http_code}\n" -o /dev/null -s ${proxy.sandbox_endpoint}/api/participants -H 'api-key: ${service.applications[0].userkey}' + def userkey = service.applications[0].userkey + sh """set -e + echo "Public Staging Base URL is ${proxy.sandbox_endpoint}" + echo "userkey is ${userkey}" + curl -sfk -w "ListBeers: %{http_code}\n" -o /dev/null ${proxy.sandbox_endpoint}/api/location -H 'api-key: ${userkey}' + curl -sfk -w "GetBeer: %{http_code}\n" -o /dev/null ${proxy.sandbox_endpoint}/api/timeframe -H 'api-key: ${userkey}' + curl -sfk -w "FindBeersByStatus: %{http_code}\n" -o /dev/null ${proxy.sandbox_endpoint}/api/participants -H 'api-key: ${userkey}' """ // Promote to production