Skip to content

Commit d7ab7d1

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 e8ac4ec commit d7ab7d1

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} "
@@ -218,20 +220,37 @@ wait_for_oidc_endpoint_docker() {
218220
calculate_rabbitmq_url() {
219221
echo "${RABBITMQ_SCHEME:-http}://$1${PUBLIC_RABBITMQ_PATH:-$RABBITMQ_PATH}"
220222
}
221-
223+
calculate_forward_proxy_url() {
224+
PROXIED_URL=$1
225+
PROXY_HOSTNAME=$2
226+
PROXY_PORT=$3
227+
SCHEME=$(echo "$PROXIED_URL" | cut -d: -f1)
228+
PATH=$(echo "$PROXIED_URL" | cut -d/ -f4-)
229+
echo "$SCHEME://$PROXY_HOSTNAME:$PROXY_PORT/$PATH"
230+
}
222231
wait_for_url() {
223-
BASE_URL=$1
232+
BASE_URL=$1
224233
if [[ $BASE_URL == *"localhost"** ]]; then
225-
wait_for_url_local $BASE_URL
234+
wait_for_url_local $@
226235
else
227-
wait_for_url_docker $BASE_URL
236+
wait_for_url_docker $@
228237
fi
229238
}
230239
wait_for_url_local() {
231240
url=$1
241+
proxy=${2:-none}
242+
proxy_user=${3:-none}
243+
proxy_pass=$4
244+
curl_args="-L -f -v"
232245
max_retry=10
233246
counter=0
234-
until (curl -k -L -f -v $url >/dev/null 2>&1)
247+
if [[ "$proxy" != "none" && "$proxy" != "" ]]; then
248+
curl_args="--proxy ${proxy} ${curl_args}"
249+
fi
250+
if [[ "$proxy_user" != "none" && "$proxy_user" != "" ]]; then
251+
curl_args="--proxy-user ${proxy_user}:${proxy_pass} ${curl_args}"
252+
fi
253+
until (curl $curl_args $url >/dev/null 2>&1)
235254
do
236255
print "Waiting for $url to start (local)"
237256
sleep 5
@@ -244,7 +263,14 @@ wait_for_url_docker() {
244263
url=$1
245264
max_retry=10
246265
counter=0
247-
until (docker run --net ${DOCKER_NETWORK} --rm curlimages/curl:7.85.0 -k -L -f -v $url >/dev/null 2>&1)
266+
curl_args="-L -f -v"
267+
if [[ "$proxy" != "none" && "$proxy" != "" ]]; then
268+
curl_args="--proxy ${proxy} ${curl_args}"
269+
fi
270+
if [[ "$proxy_user" != "none" && "$proxy_user" != "" ]]; then
271+
curl_args="--proxy-user ${proxy_user}:${proxy_pass} ${curl_args}"
272+
fi
273+
until (docker run --net ${DOCKER_NETWORK} --rm curlimages/curl:7.85.0 $curl_args $url >/dev/null 2>&1)
248274
do
249275
print "Waiting for $url to start (docker)"
250276
sleep 5
@@ -377,7 +403,8 @@ profiles_with_local_or_docker() {
377403
generate_env_file() {
378404
begin "Generating env file ..."
379405
mkdir -p $CONF_DIR
380-
${BIN_DIR}/gen-env-file $TEST_CONFIG_DIR $ENV_FILE
406+
${BIN_DIR}/gen-env-file $TEST_CONFIG_DIR ${ENV_FILE}.tmp
407+
grep -v '^#' ${ENV_FILE}.tmp > $ENV_FILE
381408
source $ENV_FILE
382409
end "Finished generating env file."
383410
}
@@ -475,6 +502,9 @@ generate-client-keystore-if-required() {
475502
fi
476503
}
477504

505+
initOnly() {
506+
determine_init_only_components $@
507+
}
478508
run() {
479509
runWith rabbitmq
480510
}
@@ -519,6 +549,12 @@ elif [[ "$COMMAND" == "stop-rabbitmq" ]]
519549
test_local ${BASH_REMATCH[1]}
520550
fi
521551
}
552+
determine_init_only_components() {
553+
for (( i=1; i<=$#; i++)) {
554+
eval val='$'$i
555+
INIT_ONLY_COMPONENTS+=( "$val" )
556+
}
557+
}
522558
determine_required_components_including_rabbitmq() {
523559
for (( i=1; i<=$#; i++)) {
524560
eval val='$'$i
@@ -545,7 +581,7 @@ run_on_docker_with() {
545581
build_mocha_image
546582
start_selenium
547583

548-
trap teardown_components EXIT
584+
trap "teardown_components" EXIT
549585

550586
start_components
551587
test
@@ -622,11 +658,27 @@ ensure_components() {
622658
start_components() {
623659
for i in "${REQUIRED_COMPONENTS[@]}"
624660
do
625-
start="start_$i"
626-
$start
661+
local ret=$(is_init_only_component $i)
662+
if [[ $ret == 1 ]]
663+
then
664+
init="init_$i"
665+
$init
666+
else
667+
start="start_$i"
668+
$start
669+
fi
627670
done
628671
}
629-
672+
is_init_only_component() {
673+
for i in "${INIT_ONLY_COMPONENTS[@]}"
674+
do
675+
if [[ $i == $1 ]]
676+
then
677+
return 1
678+
fi
679+
done
680+
return 0
681+
}
630682
teardown_components() {
631683
skip_rabbitmq=${1:-false}
632684

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)