Update multi tenancy_Integration.yml #30
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@v3 | |
| 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: | | |
| echo -e "\033[36m🔧 Installing Cloud Foundry CLI and jq...\033[0m" | |
| 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 -y cf8-cli jq | |
| echo -e "\033[32m✔️ Installation complete!\033[0m" | |
| - 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 -e "\033[34m🌐 Space determined: \033[1m$space\033[22m\033[0m" | |
| echo "::set-output name=space::$space" | |
| - name: Login to Cloud Foundry | |
| run: | | |
| echo -e "\033[36m🔑 Logging in to Cloud Foundry...\033[0m" | |
| cf login -a ${{ secrets.CF_API }} \ | |
| -u ${{ secrets.CF_USER }} \ | |
| -p ${{ secrets.CF_PASSWORD }} \ | |
| -o ${{ secrets.CF_ORG }} \ | |
| -s ${{ secrets.CF_SPACE }} > /dev/null | |
| echo -e "\033[32m✔️ Login successful!\033[0m" | |
| - name: Fetch and Mask Client Details for Single Tenant | |
| id: fetch_credentials | |
| run: | | |
| echo -e "\033[36m🚀 Fetching and Masking Client Details for Single Tenant...\033[0m" | |
| service_instance_guid=$(cf service demoappjava-public-uaa --guid) | |
| if [ -z "$service_instance_guid" ]; then | |
| echo -e "\033[31m❌ Error: Unable to retrieve service instance GUID\033[0m" | |
| 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 -e "\033[31m❌ Error: Unable to retrieve binding GUID\033[0m" | |
| 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 -e "\033[31m❌ Error: clientSecret is not set or is null\033[0m" | |
| exit 1 | |
| fi | |
| maskedClientSecret="****$(echo "$clientSecret" | sed 's/.*\(....\)$/\1/')" | |
| clientID=$(echo "$binding_details" | jq -r '.credentials.clientid') | |
| if [ -z "$clientID" ] || [ "$clientID" == "null" ]; then | |
| echo -e "\033[31m❌ Error: clientID is not set or is null\033[0m" | |
| exit 1 | |
| fi | |
| maskedClientID="****$(echo "$clientID" | sed 's/.*\(....\)$/\1/')" | |
| echo "::set-output name=CLIENT_SECRET::$maskedClientSecret" | |
| echo "::set-output name=CLIENT_ID::$maskedClientID" | |
| echo -e "\033[32m✔️ Client Details fetched and masked successfully!\033[0m" | |
| - name: Fetch and Mask Client Details for Multi Tenant | |
| id: fetch_credentials_mt | |
| run: | | |
| echo -e "\033[36m🚀 Fetching and Masking Client Details for Multi Tenant...\033[0m" | |
| service_instance_guid=$(cf service bookshop-mt-uaa --guid) | |
| if [ -z "$service_instance_guid" ]; then | |
| echo -e "\033[31m❌ Error: Unable to retrieve service instance GUID\033[0m" | |
| 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 -e "\033[31m❌ Error: Unable to retrieve binding GUID\033[0m" | |
| 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 -e "\033[31m❌ Error: clientSecret_mt is not set or is null\033[0m" | |
| exit 1 | |
| fi | |
| maskedClientSecretMT="****$(echo "$clientSecret_mt" | sed 's/.*\(....\)$/\1/')" | |
| clientID_mt=$(echo "$binding_details" | jq -r '.credentials.clientid') | |
| if [ -z "$clientID_mt" ] || [ "$clientID_mt" == "null" ]; then | |
| echo -e "\033[31m❌ Error: clientID_mt is not set or is null\033[0m" | |
| exit 1 | |
| fi | |
| maskedClientIDMT="****$(echo "$clientID_mt" | sed 's/.*\(....\)$/\1/')" | |
| echo "::set-output name=CLIENT_SECRET_MT::$maskedClientSecretMT" | |
| echo "::set-output name=CLIENT_ID_MT::$maskedClientIDMT" | |
| echo -e "\033[32m✔️ Multi Tenant Client Details fetched and masked successfully!\033[0m" | |
| - 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: | | |
| echo -e "\033[36m🧪 Running Integration Tests...\033[0m" | |
| set -e | |
| PROPERTIES_FILE="sdm/src/test/resources/credentials.properties" | |
| 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 }}" | |
| username="${{ secrets.CF_USER }}" | |
| password="${{ secrets.CF_PASSWORD }}" | |
| noSDMRoleUsername="${{ secrets.NOSDMROLEUSERNAME }}" | |
| noSDMRoleUserPassword="${{ secrets.NOSDMROLEUSERPASSWORD }}" | |
| clientID="${{ env.CLIENT_ID }}" | |
| clientSecret="${{ env.CLIENT_SECRET }}" | |
| clientIDMT="${{ env.CLIENT_ID_MT }}" | |
| clientSecretMT="${{ env.CLIENT_SECRET_MT }} | |
| cat > "$PROPERTIES_FILE" <<EOL | |
| appUrl=$appUrl | |
| appUrlMT=$appUrlMT | |
| authUrl=$authUrl | |
| authUrlMT1=$authUrlMT1 | |
| authUrlMT2=$authUrlMT2 | |
| clientID=$clientID | |
| clientSecret=$clientSecret | |
| clientIDMT=$clientIDMT | |
| clientSecretMT=$clientSecretMT | |
| username=$username | |
| password="*******" | |
| noSDMRoleUsername=$noSDMRoleUsername | |
| noSDMRoleUserPassword=$noSDMRoleUserPassword | |
| EOL | |
| # Display properties file with already masked sensitive information | |
| echo -e "\033[34m📜 Properties File:\033[0m" | |
| cat "$PROPERTIES_FILE" | |
| echo -e "\033[34m🧪 Running Maven tests for Multi Tenancy...\033[0m" | |
| # mvn clean verify -P integration-tests -DtokenFlow=namedUser -DtenancyModel=multi -Dtenant=TENANT1 -DskipUnitTests > /dev/null || { echo -e "\033[31m❌ Maven tests failed for Named User Flow (Multi Tenancy, Tenant 1)\033[0m"; exit 1; } | |
| echo -e "\033[32m✔️ Integration tests completed successfully!\033[0m" |