Skip to content

Single Tenant Integration Test πŸš€ #64

Single Tenant Integration Test πŸš€

Single Tenant Integration Test πŸš€ #64

name: Single Tenant Integration Test πŸš€
on:
workflow_dispatch:
inputs:
cf_space:
description: 'Specify the Cloud Foundry space to run integration tests on'
required: true
branch_name:
description: 'Specify the branch to use for integration tests'
required: true
jobs:
integration-test:
runs-on: ubuntu-latest
steps:
- name: Checkout repository πŸ“
uses: actions/checkout@v6
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 "πŸ”„ Installing Cloud Foundry CLI and jq..."
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
echo "βœ… Installation complete!"
- 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 "πŸ”„ Logging in to Cloud Foundry..."
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 ${{ steps.determine_space.outputs.space }}
echo "βœ… Logged in successfully!"
- name: Fetch and Escape Client Details for single tenant πŸ”
id: fetch_credentials
run: |
echo "πŸ”„ Fetching client details for single tenant..."
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
escapedClientSecret=$(echo "$clientSecret" | sed 's/\$/\\$/g')
echo "::add-mask::$escapedClientSecret"
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::$escapedClientSecret"
echo "::set-output name=CLIENT_ID::$clientID"
echo "βœ… Client details fetched successfully!"
- name: Run integration tests 🎯
env:
CLIENT_SECRET: ${{ steps.fetch_credentials.outputs.CLIENT_SECRET }}
CLIENT_ID: ${{ steps.fetch_credentials.outputs.CLIENT_ID }}
run: |
echo "πŸš€ Starting integration tests..."
set -e
PROPERTIES_FILE="sdm/src/test/resources/credentials.properties"
appUrl="${{ secrets.CF_ORG }}-${{ steps.determine_space.outputs.space }}-demoappjava-srv.cfapps.eu12.hana.ondemand.com"
authUrl="${{ secrets.CAPAUTH_URL }}"
clientID="${{ env.CLIENT_ID }}"
clientSecret="${{ env.CLIENT_SECRET }}"
username="${{ secrets.CF_USER }}"
password="${{ secrets.CF_PASSWORD }}"
noSDMRoleUsername="${{ secrets.NOSDMROLEUSERNAME }}"
noSDMRoleUserPassword="${{ secrets.NOSDMROLEUSERPASSWORD }}"
echo "::add-mask::$clientSecret"
echo "::add-mask::$clientID"
echo "::add-mask::$username"
echo "::add-mask::$password"
echo "::add-mask::$noSDMRoleUsername"
echo "::add-mask::$noSDMRoleUserPassword"
if [ -z "$appUrl" ]; then echo "❌ Error: appUrl is not set"; exit 1; fi
if [ -z "$authUrl" ]; then echo "❌ Error: authUrl is not set"; exit 1; fi
if [ -z "$clientID" ]; then echo "❌ Error: clientID is not set"; exit 1; fi
if [ -z "$clientSecret" ]; then echo "❌ Error: clientSecret is not set"; exit 1; fi
if [ -z "$username" ]; then echo "❌ Error: username is not set"; exit 1; fi
if [ -z "$password" ]; then echo "❌ Error: password is not set"; exit 1; fi
if [ -z "$noSDMRoleUsername" ]; then echo "❌ Error: noSDMRoleUsername is not set"; exit 1; fi
if [ -z "$noSDMRoleUserPassword" ]; then echo "❌ Error: noSDMRoleUserPassword is not set"; exit 1; fi
cat > "$PROPERTIES_FILE" <<EOL
appUrl=$appUrl
authUrl=$authUrl
clientID=$clientID
clientSecret=$clientSecret
username=$username
password=$password
noSDMRoleUsername=$noSDMRoleUsername
noSDMRoleUserPassword=$noSDMRoleUserPassword
EOL
echo "🎯 Running Maven integration tests..."
# Run Maven integration tests
mvn clean verify -P integration-tests -DtokenFlow=namedUser -DtenancyModel=single -DskipUnitTests || { echo "❌ Maven tests failed for Named User Flow"; exit 1; }
mvn clean verify -P integration-tests -DtokenFlow=technicalUser -DtenancyModel=single -DskipUnitTests || { echo "❌ Maven tests failed for Technical User Flow"; exit 1; }