Skip to content

Commit 3425f50

Browse files
Add initOnly function
So that it is possible to generate the certificates used by a component like uaa without starting it Some test cases test rabbitmq against an Idp which is down
1 parent 198b822 commit 3425f50

File tree

3 files changed

+65
-11
lines changed

3 files changed

+65
-11
lines changed

selenium/bin/suite_template

Lines changed: 63 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ tabs 1
1313
declare -i PADDING_LEVEL=0
1414
declare -i STEP=1
1515
declare -a REQUIRED_COMPONENTS
16+
declare -a INIT_ONLY_COMPONENTS
1617

1718
find_selenium_dir() {
1819
TEST_PATH=$1
@@ -112,6 +113,7 @@ init_suite() {
112113

113114
begin "Initializing suite $SUITE ..."
114115
print "> REQUIRED_COMPONENTS: ${REQUIRED_COMPONENTS[*]}"
116+
print "> INIT_ONLY_COMPONENTS: ${INIT_ONLY_COMPONENTS[*]}"
115117
print "> TEST_CASES_DIR: ${TEST_CASES_DIR} "
116118
print "> TEST_CONFIG_DIR: ${TEST_CONFIG_DIR} "
117119
print "> DOCKER_NETWORK: ${DOCKER_NETWORK} "
@@ -214,20 +216,37 @@ wait_for_oidc_endpoint_docker() {
214216
calculate_rabbitmq_url() {
215217
echo "${RABBITMQ_SCHEME:-http}://$1${PUBLIC_RABBITMQ_PATH:-$RABBITMQ_PATH}"
216218
}
217-
219+
calculate_forward_proxy_url() {
220+
PROXIED_URL=$1
221+
PROXY_HOSTNAME=$2
222+
PROXY_PORT=$3
223+
SCHEME=$(echo "$PROXIED_URL" | cut -d: -f1)
224+
PATH=$(echo "$PROXIED_URL" | cut -d/ -f4-)
225+
echo "$SCHEME://$PROXY_HOSTNAME:$PROXY_PORT/$PATH"
226+
}
218227
wait_for_url() {
219-
BASE_URL=$1
228+
BASE_URL=$1
220229
if [[ $BASE_URL == *"localhost"** ]]; then
221-
wait_for_url_local $BASE_URL
230+
wait_for_url_local $@
222231
else
223-
wait_for_url_docker $BASE_URL
232+
wait_for_url_docker $@
224233
fi
225234
}
226235
wait_for_url_local() {
227236
url=$1
237+
proxy=${2:-none}
238+
proxy_user=${3:-none}
239+
proxy_pass=$4
240+
curl_args="-L -f -v"
228241
max_retry=10
229242
counter=0
230-
until (curl -k -L -f -v $url >/dev/null 2>&1)
243+
if [[ "$proxy" != "none" && "$proxy" != "" ]]; then
244+
curl_args="--proxy ${proxy} ${curl_args}"
245+
fi
246+
if [[ "$proxy_user" != "none" && "$proxy_user" != "" ]]; then
247+
curl_args="--proxy-user ${proxy_user}:${proxy_pass} ${curl_args}"
248+
fi
249+
until (curl $curl_args $url >/dev/null 2>&1)
231250
do
232251
print "Waiting for $url to start (local)"
233252
sleep 5
@@ -240,7 +259,14 @@ wait_for_url_docker() {
240259
url=$1
241260
max_retry=10
242261
counter=0
243-
until (docker run --net ${DOCKER_NETWORK} --rm curlimages/curl:7.85.0 -k -L -f -v $url >/dev/null 2>&1)
262+
curl_args="-L -f -v"
263+
if [[ "$proxy" != "none" && "$proxy" != "" ]]; then
264+
curl_args="--proxy ${proxy} ${curl_args}"
265+
fi
266+
if [[ "$proxy_user" != "none" && "$proxy_user" != "" ]]; then
267+
curl_args="--proxy-user ${proxy_user}:${proxy_pass} ${curl_args}"
268+
fi
269+
until (docker run --net ${DOCKER_NETWORK} --rm curlimages/curl:7.85.0 $curl_args $url >/dev/null 2>&1)
244270
do
245271
print "Waiting for $url to start (docker)"
246272
sleep 5
@@ -373,7 +399,8 @@ profiles_with_local_or_docker() {
373399
generate_env_file() {
374400
begin "Generating env file ..."
375401
mkdir -p $CONF_DIR
376-
${BIN_DIR}/gen-env-file $TEST_CONFIG_DIR $ENV_FILE
402+
${BIN_DIR}/gen-env-file $TEST_CONFIG_DIR ${ENV_FILE}.tmp
403+
grep -v '^#' ${ENV_FILE}.tmp > $ENV_FILE
377404
source $ENV_FILE
378405
end "Finished generating env file."
379406
}
@@ -471,6 +498,9 @@ generate-client-keystore-if-required() {
471498
fi
472499
}
473500

501+
initOnly() {
502+
determine_init_only_components $@
503+
}
474504
run() {
475505
runWith rabbitmq
476506
}
@@ -515,6 +545,12 @@ elif [[ "$COMMAND" == "stop-rabbitmq" ]]
515545
test_local ${BASH_REMATCH[1]}
516546
fi
517547
}
548+
determine_init_only_components() {
549+
for (( i=1; i<=$#; i++)) {
550+
eval val='$'$i
551+
INIT_ONLY_COMPONENTS+=( "$val" )
552+
}
553+
}
518554
determine_required_components_including_rabbitmq() {
519555
for (( i=1; i<=$#; i++)) {
520556
eval val='$'$i
@@ -541,7 +577,7 @@ run_on_docker_with() {
541577
build_mocha_image
542578
start_selenium
543579

544-
trap teardown_components EXIT
580+
trap "teardown_components" EXIT
545581

546582
start_components
547583
test
@@ -618,11 +654,27 @@ ensure_components() {
618654
start_components() {
619655
for i in "${REQUIRED_COMPONENTS[@]}"
620656
do
621-
start="start_$i"
622-
$start
657+
local ret=$(is_init_only_component $i)
658+
if [[ $ret == 1 ]]
659+
then
660+
init="init_$i"
661+
$init
662+
else
663+
start="start_$i"
664+
$start
665+
fi
623666
done
624667
}
625-
668+
is_init_only_component() {
669+
for i in "${INIT_ONLY_COMPONENTS[@]}"
670+
do
671+
if [[ $i == $1 ]]
672+
then
673+
return 1
674+
fi
675+
done
676+
return 0
677+
}
626678
teardown_components() {
627679
skip_rabbitmq=${1:-false}
628680

selenium/suites/authnz-mgt/multi-oauth-with-basic-auth-when-idps-down.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ TEST_CONFIG_PATH=/multi-oauth
77
PROFILES="devkeycloak prodkeycloak enable-basic-auth with-resource-label with-resource-scopes tls"
88

99
source $SCRIPT/../../bin/suite_template $@
10+
initOnly devkeycloak prodkeycloak
1011
run

selenium/suites/authnz-mgt/oauth-with-uaa-down.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ TEST_CONFIG_PATH=/oauth
77
PROFILES="uaa uaa-oauth-provider uaa-mgt-oauth-provider"
88

99
source $SCRIPT/../../bin/suite_template $@
10+
initOnly uaa
1011
run

0 commit comments

Comments
 (0)