Skip to content

Commit 09a14ec

Browse files
Update multi tenancy_Integration.yml
1 parent eff0b20 commit 09a14ec

1 file changed

Lines changed: 50 additions & 40 deletions

File tree

Lines changed: 50 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
name: Multi Tenancy Integration Test
22

33
on:
4+
push:
5+
branches:
6+
- multiTenancy_IntegrationTest
47
workflow_dispatch:
58
inputs:
69
cf_space:
@@ -19,7 +22,7 @@ jobs:
1922

2023
steps:
2124
- name: Checkout repository
22-
uses: actions/checkout@v2
25+
uses: actions/checkout@v3
2326
with:
2427
ref: ${{ github.event.inputs.branch_name }}
2528

@@ -31,10 +34,12 @@ jobs:
3134

3235
- name: Install Cloud Foundry CLI and jq
3336
run: |
37+
echo -e "\033[36mInstalling Cloud Foundry CLI and jq...\033[0m"
3438
wget -q -O - https://packages.cloudfoundry.org/debian/cli.cloudfoundry.org.key | sudo apt-key add -
3539
echo "deb https://packages.cloudfoundry.org/debian stable main" | sudo tee /etc/apt/sources.list.d/cloudfoundry-cli.list
3640
sudo apt-get update
37-
sudo apt-get install cf8-cli jq
41+
sudo apt-get install -y cf8-cli jq
42+
echo -e "\033[32mInstallation complete!\033[0m"
3843
3944
- name: Determine Cloud Foundry Space
4045
id: determine_space
@@ -44,78 +49,90 @@ jobs:
4449
else
4550
space="${{ github.event.inputs.cf_space }}"
4651
fi
47-
echo "Space determined: $space"
52+
echo -e "\033[34mSpace determined: \033[1m$space\033[22m\033[0m"
4853
echo "::set-output name=space::$space"
4954
5055
- name: Login to Cloud Foundry
5156
run: |
52-
echo "Space Name: ${{ steps.determine_space.outputs.space }}"
57+
echo -e "\033[36mLogging in to Cloud Foundry...\033[0m"
5358
cf login -a ${{ secrets.CF_API }} \
5459
-u ${{ secrets.CF_USER }} \
5560
-p ${{ secrets.CF_PASSWORD }} \
5661
-o ${{ secrets.CF_ORG }} \
5762
-s ${{ steps.determine_space.outputs.space }}
63+
echo -e "\033[32mLogin successful!\033[0m"
5864
5965
- name: Fetch and Escape Client Details for single tenant
6066
id: fetch_credentials
6167
run: |
68+
echo -e "\033[36mFetching Client Details for Single Tenant...\033[0m"
6269
service_instance_guid=$(cf service demoappjava-public-uaa --guid)
6370
if [ -z "$service_instance_guid" ]; then
64-
echo "Error: Unable to retrieve service instance GUID"; exit 1;
71+
echo -e "\033[31mError: Unable to retrieve service instance GUID\033[0m"
72+
exit 1
6573
fi
6674
6775
bindings_response=$(cf curl "/v3/service_credential_bindings?service_instance_guids=${service_instance_guid}")
6876
binding_guid=$(echo $bindings_response | jq -r '.resources[0].guid')
6977
if [ -z "$binding_guid" ]; then
70-
echo "Error: Unable to retrieve binding GUID"; exit 1;
78+
echo -e "\033[31mError: Unable to retrieve binding GUID\033[0m"
79+
exit 1
7180
fi
7281
7382
binding_details=$(cf curl "/v3/service_credential_bindings/${binding_guid}/details")
7483
7584
clientSecret=$(echo "$binding_details" | jq -r '.credentials.clientsecret')
7685
if [ -z "$clientSecret" ] || [ "$clientSecret" == "null" ]; then
77-
echo "Error: clientSecret is not set or is null"; exit 1;
86+
echo -e "\033[31mError: clientSecret is not set or is null\033[0m"
87+
exit 1
7888
fi
7989
escapedClientSecret=$(echo "$clientSecret" | sed 's/\$/\\$/g')
8090
8191
clientID=$(echo "$binding_details" | jq -r '.credentials.clientid')
8292
if [ -z "$clientID" ] || [ "$clientID" == "null" ]; then
83-
echo "Error: clientID is not set or is null"; exit 1;
93+
echo -e "\033[31mError: clientID is not set or is null\033[0m"
94+
exit 1
8495
fi
8596
8697
echo "::set-output name=CLIENT_SECRET::$escapedClientSecret"
8798
echo "::set-output name=CLIENT_ID::$clientID"
99+
echo -e "\033[32mClient Details fetched successfully!\033[0m"
88100
89101
- name: Fetch and Escape Client Details for multi tenant
90102
id: fetch_credentials_mt
91103
run: |
104+
echo -e "\033[36mFetching Client Details for Multi Tenant...\033[0m"
92105
service_instance_guid=$(cf service bookshop-mt-uaa --guid)
93106
if [ -z "$service_instance_guid" ]; then
94-
echo "Error: Unable to retrieve service instance GUID"; exit 1;
107+
echo -e "\033[31mError: Unable to retrieve service instance GUID\033[0m"
108+
exit 1
95109
fi
96110
97111
bindings_response=$(cf curl "/v3/service_credential_bindings?service_instance_guids=${service_instance_guid}")
98112
binding_guid=$(echo $bindings_response | jq -r '.resources[0].guid')
99113
if [ -z "$binding_guid" ]; then
100-
echo "Error: Unable to retrieve binding GUID"; exit 1;
114+
echo -e "\033[31mError: Unable to retrieve binding GUID\033[0m"
115+
exit 1
101116
fi
102117
103118
binding_details=$(cf curl "/v3/service_credential_bindings/${binding_guid}/details")
104119
105120
clientSecret_mt=$(echo "$binding_details" | jq -r '.credentials.clientsecret')
106121
if [ -z "$clientSecret_mt" ] || [ "$clientSecret_mt" == "null" ]; then
107-
echo "Error: clientSecret_mt is not set or is null"; exit 1;
122+
echo -e "\033[31mError: clientSecret_mt is not set or is null\033[0m"
123+
exit 1
108124
fi
109125
escapedClientSecret_mt=$(echo "$clientSecret_mt" | sed 's/\$/\\$/g')
110126
111127
clientID_mt=$(echo "$binding_details" | jq -r '.credentials.clientid')
112128
if [ -z "$clientID_mt" ] || [ "$clientID_mt" == "null" ]; then
113-
echo "Error: clientID_mt is not set or is null"; exit 1;
129+
echo -e "\033[31mError: clientID_mt is not set or is null\033[0m"
130+
exit 1
114131
fi
115132
116133
echo "::set-output name=CLIENT_SECRET_MT::$escapedClientSecret_mt"
117134
echo "::set-output name=CLIENT_ID_MT::$clientID_mt"
118-
135+
echo -e "\033[32mMulti Tenant Client Details fetched successfully!\033[0m"
119136
120137
- name: Run integration tests
121138
env:
@@ -124,6 +141,7 @@ jobs:
124141
CLIENT_SECRET_MT: ${{ steps.fetch_credentials_mt.outputs.CLIENT_SECRET_MT }}
125142
CLIENT_ID_MT: ${{ steps.fetch_credentials_mt.outputs.CLIENT_ID_MT }}
126143
run: |
144+
echo -e "\033[36mRunning Integration Tests...\033[0m"
127145
set -e
128146
PROPERTIES_FILE="sdm/src/test/resources/credentials.properties"
129147
appUrl="${{ secrets.CF_ORG }}-${{ steps.determine_space.outputs.space }}-demoappjava-srv.cfapps.eu12.hana.ondemand.com"
@@ -139,28 +157,14 @@ jobs:
139157
password="${{ secrets.CF_PASSWORD }}"
140158
noSDMRoleUsername="${{ secrets.NOSDMROLEUSERNAME }}"
141159
noSDMRoleUserPassword="${{ secrets.NOSDMROLEUSERPASSWORD }}"
142-
if [ -z "$appUrl" ]; then echo "Error: appUrl is not set"; exit 1; fi
143-
if [ -z "$appUrlMT" ]; then echo "Error: appUrlMT is not set"; exit 1; fi
144-
if [ -z "$authUrl" ]; then echo "Error: authUrl is not set"; exit 1; fi
145-
if [ -z "$authUrlMT1" ]; then echo "Error: authUrlMT1 is not set"; exit 1; fi
146-
if [ -z "$authUrlMT2" ]; then echo "Error: authUrlMT2 is not set"; exit 1; fi
147-
if [ -z "$clientID" ]; then echo "Error: clientID is not set"; exit 1; fi
148-
if [ -z "$clientSecret" ]; then echo "Error: clientSecret is not set"; exit 1; fi
149-
if [ -z "$clientIDMT" ]; then echo "Error: clientIDMT is not set"; exit 1; fi
150-
if [ -z "$clientSecretMT" ]; then echo "Error: clientSecretMT is not set"; exit 1; fi
151-
if [ -z "$username" ]; then echo "Error: username is not set"; exit 1; fi
152-
if [ -z "$password" ]; then echo "Error: password is not set"; exit 1; fi
153-
if [ -z "$noSDMRoleUsername" ]; then echo "Error: noSDMRoleUsername is not set"; exit 1; fi
154-
if [ -z "$noSDMRoleUserPassword" ]; then echo "Error: noSDMRoleUserPassword is not set"; exit 1; fi
155-
156-
mask() {
157-
local value="$1"
158-
if [ ${#value} -gt 6 ]; then
159-
echo "${value:0:3}*****${value: -3}"
160-
else
161-
echo "${value:0:2}*****"
160+
161+
# Check for missing variables
162+
for var in appUrl appUrlMT authUrl authUrlMT1 authUrlMT2 clientID clientSecret clientIDMT clientSecretMT username password noSDMRoleUsername noSDMRoleUserPassword; do
163+
if [ -z "${!var}" ]; then
164+
echo -e "\033[31mError: ${var} is not set\033[0m"
165+
exit 1
162166
fi
163-
}
167+
done
164168
165169
cat > "$PROPERTIES_FILE" <<EOL
166170
appUrl=$appUrl
@@ -178,10 +182,16 @@ jobs:
178182
noSDMRoleUserPassword=$noSDMRoleUserPassword
179183
EOL
180184
185+
# Display properties file
186+
echo -e "\033[34mProperties File:\033[0m"
187+
cat "$PROPERTIES_FILE"
188+
181189
# Run Maven integration tests
182-
# mvn clean verify -P integration-tests -DtokenFlow=namedUser -DtenancyModel=single -DskipUnitTests || { echo "Maven tests failed for Technical User Flow"; exit 1; }
183-
# mvn clean verify -P integration-tests -DtokenFlow=technicalUser -DtenancyModel=single -DskipUnitTests || { echo "Maven tests failed for Named User Flow"; exit 1; }
184-
mvn clean verify -P integration-tests -DtokenFlow=namedUser -DtenancyModel=multi -Dtenant=TENANT1 -DskipUnitTests
185-
mvn clean verify -P integration-tests -DtokenFlow=technicalUser -DtenancyModel=multi -Dtenant=TENANT1 -DskipUnitTests
186-
mvn clean verify -P integration-tests -DtokenFlow=namedUser -DtenancyModel=multi -Dtenant=TENANT2 -DskipUnitTests
187-
mvn clean verify -P integration-tests -DtokenFlow=technicalUser -DtenancyModel=multi -Dtenant=TENANT2 -DskipUnitTests
190+
191+
echo -e "\033[34mRunning Maven tests for Multi Tenancy...\033[0m"
192+
mvn clean verify -P integration-tests -DtokenFlow=namedUser -DtenancyModel=multi -Dtenant=TENANT1 -DskipUnitTests || { echo -e "\033[31mMaven tests failed for Named User Flow (Multi Tenancy, Tenant 1)\033[0m"; exit 1; }
193+
# mvn clean verify -P integration-tests -DtokenFlow=technicalUser -DtenancyModel=multi -Dtenant=TENANT1 -DskipUnitTests || { echo -e "\033[31mMaven tests failed for Technical User Flow (Multi Tenancy, Tenant 1)\033[0m"; exit 1; }
194+
# mvn clean verify -P integration-tests -DtokenFlow=namedUser -DtenancyModel=multi -Dtenant=TENANT2 -DskipUnitTests || { echo -e "\033[31mMaven tests failed for Named User Flow (Multi Tenancy, Tenant 2)\033[0m"; exit 1; }
195+
# mvn clean verify -P integration-tests -DtokenFlow=technicalUser -DtenancyModel=multi -Dtenant=TENANT2 -DskipUnitTests || { echo -e "\033[31mMaven tests failed for Technical User Flow (Multi Tenancy, Tenant 2)\033[0m"; exit 1; }
196+
197+
echo -e "\033[32mIntegration tests completed successfully!\033[0m"

0 commit comments

Comments
 (0)