Update multi tenancy_Integration.yml #37
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Multi Tenancy Integration Test | |
| on: | |
| push: | |
| branches: | |
| - multiTenancy_IntegrationTest | |
| workflow_dispatch: | |
| inputs: | |
| cf_space: | |
| description: 'Specify the Cloud Foundry space to run integration tests on' | |
| required: true | |
| default: developcap | |
| branch_name: | |
| description: 'Specify the branch to use for integration tests' | |
| required: true | |
| default: develop | |
| jobs: | |
| integration-test: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v2 | |
| with: | |
| ref: ${{ github.event.inputs.branch_name }} | |
| - name: Set up Java 17 | |
| uses: actions/setup-java@v3 | |
| with: | |
| java-version: 17 | |
| distribution: 'temurin' | |
| - name: Install Cloud Foundry CLI and jq | |
| run: | | |
| wget -q -O - https://packages.cloudfoundry.org/debian/cli.cloudfoundry.org.key | sudo apt-key add - | |
| echo "deb https://packages.cloudfoundry.org/debian stable main" | sudo tee /etc/apt/sources.list.d/cloudfoundry-cli.list | |
| sudo apt-get update | |
| sudo apt-get install cf8-cli jq | |
| - name: Determine Cloud Foundry Space | |
| id: determine_space | |
| run: | | |
| if [ "${{ github.event.inputs.cf_space }}" == "developcap" ]; then | |
| space="${{ secrets.CF_SPACE }}" | |
| else | |
| space="${{ github.event.inputs.cf_space }}" | |
| fi | |
| echo "Space determined: $space" | |
| echo "::set-output name=space::$space" | |
| - name: Login to Cloud Foundry | |
| run: | | |
| echo "Space Name: ${{ steps.determine_space.outputs.space }}" | |
| cf login -a ${{ secrets.CF_API }} \ | |
| -u ${{ secrets.CF_USER }} \ | |
| -p ${{ secrets.CF_PASSWORD }} \ | |
| -o ${{ secrets.CF_ORG }} \ | |
| -s ${{ secrets.CF_SPACE }} | |
| # -s ${{ steps.determine_space.outputs.space }} | |
| - name: Fetch and Escape Client Details for single tenant | |
| id: fetch_credentials | |
| run: | | |
| set -e | |
| service_instance_guid=$(cf service demoappjava-public-uaa --guid) | |
| if [ -z "$service_instance_guid" ]; then | |
| echo "Error: Unable to retrieve service instance GUID"; exit 1; | |
| fi | |
| bindings_response=$(cf curl "/v3/service_credential_bindings?service_instance_guids=${service_instance_guid}") | |
| binding_guid=$(echo $bindings_response | jq -r '.resources[0].guid') | |
| if [ -z "$binding_guid" ]; then | |
| echo "Error: Unable to retrieve binding GUID"; exit 1; | |
| fi | |
| binding_details=$(cf curl "/v3/service_credential_bindings/${binding_guid}/details") | |
| clientSecret=$(echo "$binding_details" | jq -r '.credentials.clientsecret') | |
| if [ -z "$clientSecret" ] || [ "$clientSecret" == "null" ]; then | |
| echo "Error: clientSecret is not set or is null"; exit 1; | |
| fi | |
| clientSecretMasked=$(echo "$clientSecret" | sed 's/\$/\\$/g') | |
| echo "::add-mask::$clientSecretMasked" | |
| clientID=$(echo "$binding_details" | jq -r '.credentials.clientid') | |
| if [ -z "$clientID" ] || [ "$clientID" == "null" ]; then | |
| echo "Error: clientID is not set or is null"; exit 1; | |
| fi | |
| echo "::add-mask::$clientID" | |
| echo "::set-output name=CLIENT_SECRET::$clientSecretMasked" | |
| echo "::set-output name=CLIENT_ID::$clientID" | |
| - name: Fetch and Escape Client Details for multi tenant | |
| id: fetch_credentials_mt | |
| run: | | |
| set -e | |
| service_instance_guid=$(cf service bookshop-mt-uaa --guid) | |
| if [ -z "$service_instance_guid" ]; then | |
| echo "Error: Unable to retrieve service instance GUID"; exit 1; | |
| fi | |
| bindings_response=$(cf curl "/v3/service_credential_bindings?service_instance_guids=${service_instance_guid}") | |
| binding_guid=$(echo $bindings_response | jq -r '.resources[0].guid') | |
| if [ -z "$binding_guid" ]; then | |
| echo "Error: Unable to retrieve binding GUID"; exit 1; | |
| fi | |
| binding_details=$(cf curl "/v3/service_credential_bindings/${binding_guid}/details") | |
| clientSecret_mt=$(echo "$binding_details" | jq -r '.credentials.clientsecret') | |
| if [ -z "$clientSecret_mt" ] || [ "$clientSecret_mt" == "null" ]; then | |
| echo "Error: clientSecret_mt is not set or is null"; exit 1; | |
| fi | |
| clientSecretMasked_mt=$(echo "$clientSecret_mt" | sed 's/\$/\\$/g') | |
| echo "::add-mask::$clientSecretMasked_mt" | |
| clientID_mt=$(echo "$binding_details" | jq -r '.credentials.clientid') | |
| if [ -z "$clientID_mt" ] || [ "$clientID_mt" == "null" ]; then | |
| echo "Error: clientID_mt is not set or is null"; exit 1; | |
| fi | |
| echo "::add-mask::$clientID_mt" | |
| echo "::set-output name=CLIENT_SECRET_MT::$clientSecretMasked_mt" | |
| echo "::set-output name=CLIENT_ID_MT::$clientID_mt" | |
| - name: Run integration tests | |
| env: | |
| CLIENT_SECRET: ${{ steps.fetch_credentials.outputs.CLIENT_SECRET }} | |
| CLIENT_ID: ${{ steps.fetch_credentials.outputs.CLIENT_ID }} | |
| CLIENT_SECRET_MT: ${{ steps.fetch_credentials_mt.outputs.CLIENT_SECRET_MT }} | |
| CLIENT_ID_MT: ${{ steps.fetch_credentials_mt.outputs.CLIENT_ID_MT }} | |
| run: | | |
| set -e | |
| PROPERTIES_FILE="sdm/src/test/resources/credentials.properties" | |
| declare -A variables=( | |
| ["appUrl"]="${{ secrets.CF_ORG }}-${{ secrets.CF_SPACE }}-demoappjava-srv.cfapps.eu12.hana.ondemand.com" | |
| ["appUrlMT"]="${{ secrets.CF_ORG }}-${{ secrets.CF_SPACE }}-bookshop-mt-srv.cfapps.eu12.hana.ondemand.com" | |
| ["authUrl"]="${{ secrets.CAPAUTH_URL }}" | |
| ["authUrlMT1"]="${{ secrets.AUTHURLMT1 }}" | |
| ["authUrlMT2"]="${{ secrets.AUTHURLMT2 }}" | |
| ["clientID"]="${{ env.CLIENT_ID }}" | |
| ["clientSecret"]="${{ env.CLIENT_SECRET }}" | |
| ["clientIDMT"]="${{ env.CLIENT_ID_MT }}" | |
| ["clientSecretMT"]="${{ env.CLIENT_SECRET_MT }}" | |
| ["username"]="${{ secrets.CF_USER }}" | |
| ["password"]="${{ secrets.CF_PASSWORD }}" | |
| ["noSDMRoleUsername"]="${{ secrets.NOSDMROLEUSERNAME }}" | |
| ["noSDMRoleUserPassword"]="${{ secrets.NOSDMROLEUSERPASSWORD }}" | |
| ) | |
| mask() { | |
| local value="$1" | |
| if [ ${#value} -gt 6 ]; then | |
| echo "${value:0:3}*****${value: -3}" | |
| else | |
| echo "${value:0:2}*****" | |
| fi | |
| } | |
| # Mask all secrets in logs | |
| for key in "${!variables[@]}"; do | |
| echo "::add-mask::${variables[$key]}" | |
| if [ -z "${variables[$key]}" ]; then | |
| echo "Error: $key is not set" | |
| exit 1 | |
| fi | |
| done | |
| # Write to the properties file | |
| cat > "$PROPERTIES_FILE" <<EOL | |
| appUrl=${variables["appUrl"]} | |
| appUrlMT=${variables["appUrlMT"]} | |
| authUrl=${variables["authUrl"]} | |
| authUrlMT1=${variables["authUrlMT1"]} | |
| authUrlMT2=${variables["authUrlMT2"]} | |
| clientID=$(mask "${variables["clientID"]}") | |
| clientSecret=$(mask "${variables["clientSecret"]}") | |
| clientIDMT=$(mask "${variables["clientIDMT"]}") | |
| clientSecretMT=$(mask "${variables["clientSecretMT"]}") | |
| username=$(mask "${variables["username"]}") | |
| password=$(mask "${variables["password"]}") | |
| noSDMRoleUsername=$(mask "${variables["noSDMRoleUsername"]}") | |
| noSDMRoleUserPassword=$(mask "${variables["noSDMRoleUserPassword"]}") | |
| EOL | |
| # Run Maven integration tests | |
| mvn clean verify -P integration-tests -DtokenFlow=namedUser -DtenancyModel=multi -Dtenant=TENANT1 -DskipUnitTests | |
| # mvn clean verify -P integration-tests -DtokenFlow=technicalUser -DtenancyModel=multi -Dtenant=TENANT1 -DskipUnitTests | |
| # mvn clean verify -P integration-tests -DtokenFlow=namedUser -DtenancyModel=multi -Dtenant=TENANT2 -DskipUnitTests | |
| # mvn clean verify -P integration-tests -DtokenFlow=technicalUser -DtenancyModel=multi -Dtenant=TENANT2 -DskipUnitTests |