Skip to content
This repository was archived by the owner on Jun 26, 2024. It is now read-only.

Commit 9b3a8ec

Browse files
authored
Create non-admin user for acceptance tests only if it does not exist (#1131)
Signed-off-by: Pavel Macík <[email protected]>
1 parent f10f7f8 commit 9b3a8ec

File tree

1 file changed

+17
-12
lines changed

1 file changed

+17
-12
lines changed

test/acceptance/openshift-setup.sh

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,24 @@ HTPASSWD_SECRET=acceptance-tests-htpass
77
USER=acceptance-tests-dev
88
USER_TOKEN=acceptance-tests-dev
99

10-
oc get secret $HTPASSWD_SECRET -n openshift-config >/dev/null 2>&1 \
11-
|| oc create secret generic $HTPASSWD_SECRET --from-file=htpasswd=$HTPASSWD_FILE -n openshift-config
12-
13-
oc patch oauth cluster --type merge -p '{"spec":{"identityProviders":[{"htpasswd":{"fileData":{"name":"'$HTPASSWD_SECRET'"}},"mappingMethod":"claim","name":"acceptance-tests","challenge":"true","login":true,"type":"HTPasswd"}]}}'
14-
1510
CURRENT_CTX=$(oc config current-context)
16-
17-
retries=50
18-
until [[ $retries == 0 ]]; do
19-
oc login -u $USER -p $USER_TOKEN && break
20-
sleep 5
21-
retries=$(($retries - 1))
22-
done
11+
oc login -u $USER -p $USER_TOKEN --loglevel=10 --insecure-skip-tls-verify=true
12+
13+
if [ $? -eq 0 ]; then
14+
echo "User $USER is already set up, skipping..."
15+
else
16+
oc get secret $HTPASSWD_SECRET -n openshift-config >/dev/null 2>&1 \
17+
|| oc create secret generic $HTPASSWD_SECRET --from-file=htpasswd=$HTPASSWD_FILE -n openshift-config
18+
19+
oc patch oauth cluster --type merge -p '{"spec":{"identityProviders":[{"htpasswd":{"fileData":{"name":"'$HTPASSWD_SECRET'"}},"mappingMethod":"claim","name":"acceptance-tests","challenge":"true","login":true,"type":"HTPasswd"}]}}'
20+
21+
retries=50
22+
until [[ $retries == 0 ]]; do
23+
oc login -u $USER -p $USER_TOKEN && break
24+
sleep 5
25+
retries=$(($retries - 1))
26+
done;
27+
fi
2328

2429
oc config set-credentials $USER --token=$(oc whoami --show-token)
2530

0 commit comments

Comments
 (0)