Skip to content

Commit 2d8c27b

Browse files
WIP Adding proxy selenium suite
1 parent 9435fe9 commit 2d8c27b

15 files changed

+615
-16
lines changed
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
2+
HTTPD_DOCKER_IMAGE=httpd:latest
3+
4+
ensure_oauth-proxy() {
5+
if docker ps | grep oauth-proxy &> /dev/null; then
6+
print "oauth-proxy already running ..."
7+
else
8+
start_oauth-proxy
9+
fi
10+
}
11+
init_oauth-proxy() {
12+
HTTPD_CONFIG_DIR=${TEST_CONFIG_DIR}/oauth-proxy
13+
PROXY_HOSTNAME=oauth-proxy
14+
PROXY_PORT=9092
15+
16+
print "> HTTPD_CONFIG: ${HTTPD_CONFIG_DIR}"
17+
print "> OAUTH_PROVIDER_URL: ${OAUTH_PROVIDER_URL}"
18+
print "> PROXY_HOSTNAME: ${PROXY_HOSTNAME}"
19+
print "> PROXY_PORT: ${PROXY_PORT}"
20+
}
21+
start_oauth-proxy() {
22+
begin "Starting oauth-proxy ..."
23+
24+
init_oauth-proxy
25+
kill_container_if_exist oauth-proxy
26+
27+
MOUNT_HTTPD_CONFIG_DIR=$CONF_DIR/httpd
28+
29+
mkdir -p $MOUNT_HTTPD_CONFIG_DIR
30+
${BIN_DIR}/gen-httpd-conf ${HTTPD_CONFIG_DIR} $ENV_FILE $MOUNT_HTTPD_CONFIG_DIR/httpd.conf
31+
print "> EFFECTIVE HTTPD_CONFIG_FILE: $MOUNT_HTTPD_CONFIG_DIR/httpd.conf"
32+
33+
docker run \
34+
--detach \
35+
--name oauth-proxy \
36+
--net ${DOCKER_NETWORK} \
37+
--publish 9092:9092 \
38+
--mount "type=bind,source=${MOUNT_HTTPD_CONFIG_DIR},target=/usr/local/apache2/conf" \
39+
${HTTPD_DOCKER_IMAGE}
40+
41+
PROXY_URL=$(calculate_forward_proxy_url $OAUTH_PROVIDER_URL $PROXY_HOSTNAME $PROXY_PORT)
42+
43+
end "Proxy is ready"
44+
}

selenium/bin/suite_template

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -214,20 +214,37 @@ wait_for_oidc_endpoint_docker() {
214214
calculate_rabbitmq_url() {
215215
echo "${RABBITMQ_SCHEME:-http}://$1${PUBLIC_RABBITMQ_PATH:-$RABBITMQ_PATH}"
216216
}
217-
217+
calculate_forward_proxy_url() {
218+
PROXIED_URL=$1
219+
PROXY_HOSTNAME=$2
220+
PROXY_PORT=$3
221+
SCHEME=$(echo "$PROXIED_URL" | cut -d: -f1)
222+
PATH=$(echo "$PROXIED_URL" | cut -d/ -f4-)
223+
echo "$SCHEME://$PROXY_HOSTNAME:$PROXY_PORT/$PATH"
224+
}
218225
wait_for_url() {
219-
BASE_URL=$1
226+
BASE_URL=$1
220227
if [[ $BASE_URL == *"localhost"** ]]; then
221-
wait_for_url_local $BASE_URL
228+
wait_for_url_local $@
222229
else
223-
wait_for_url_docker $BASE_URL
230+
wait_for_url_docker $@
224231
fi
225232
}
226233
wait_for_url_local() {
227234
url=$1
235+
proxy=${2:-none}
236+
proxy_user=${3:-none}
237+
proxy_pass=$4
238+
curl_args="-L -f -v"
228239
max_retry=10
229240
counter=0
230-
until (curl -L -f -v $url >/dev/null 2>&1)
241+
if [[ "$proxy" != "none" ]]; then
242+
curl_args="--proxy ${proxy} ${curl_args}"
243+
fi
244+
if [[ "$proxy_user" != "none" ]]; then
245+
curl_args="--proxy-user ${proxy_user}:${proxy_pass} ${curl_args}"
246+
fi
247+
until (curl $curl_args $url >/dev/null 2>&1)
231248
do
232249
print "Waiting for $url to start (local)"
233250
sleep 5
@@ -240,7 +257,14 @@ wait_for_url_docker() {
240257
url=$1
241258
max_retry=10
242259
counter=0
243-
until (docker run --net ${DOCKER_NETWORK} --rm curlimages/curl:7.85.0 -L -f -v $url >/dev/null 2>&1)
260+
curl_args="-L -f -v"
261+
if [[ "$proxy" != "none" ]]; then
262+
curl_args="--proxy ${proxy} ${curl_args}"
263+
fi
264+
if [[ "$proxy_user" != "none" ]]; then
265+
curl_args="--proxy-user ${proxy_user}:${proxy_pass} ${curl_args}"
266+
fi
267+
until (docker run --net ${DOCKER_NETWORK} --rm curlimages/curl:7.85.0 $curl_args $url >/dev/null 2>&1)
244268
do
245269
print "Waiting for $url to start (docker)"
246270
sleep 5

selenium/full-suite-management-ui

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ authnz-mgt/oauth-idp-initiated-with-uaa-and-prefix.sh
1111
authnz-mgt/oauth-idp-initiated-with-uaa-via-proxy.sh
1212
authnz-mgt/oauth-idp-initiated-with-uaa.sh
1313
authnz-mgt/oauth-with-keycloak.sh
14+
authnz-mgt/oauth-with-keycloak-via-proxy.sh
1415
authnz-mgt/oauth-with-keycloak-with-verify-none.sh
1516
authnz-mgt/oauth-with-uaa-down-but-with-basic-auth.sh
1617
authnz-mgt/oauth-with-uaa-down.sh
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/usr/bin/env bash
2+
3+
SCRIPT="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
4+
5+
TEST_CASES_PATH=/oauth/with-sp-initiated
6+
TEST_CONFIG_PATH=/oauth
7+
PROFILES="oauth-proxy keycloak proxy-oauth-provider keycloak-mgt-oauth-provider tls"
8+
9+
source $SCRIPT/../../bin/suite_template $@
10+
runWith keycloak forward-proxy
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
export KEYCLOAK_URL=https://keycloak:8443/realms/test
2-
export OAUTH_PROVIDER_URL=https://keycloak:8443/realms/test
3-
export OAUTH_PROVIDER_CA_CERT=/config/oauth/keycloak/ca_keycloak_certificate.pem
2+
#export OAUTH_PROVIDER_URL=https://keycloak:8443/realms/test
3+
export KEYCLOAK_CA_CERT=/config/oauth/keycloak/ca_keycloak_certificate.pem
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#export OAUTH_PROVIDER_URL=https://proxy:9090/realms/test
2+
export PROXY_CA_CERT=/config/oauth/httpd-proxy/ca_httpd-proxy_certificate.pem
3+
export PROXY_URL=https://proxy:9090/realms/test
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
# export OAUTH_PROVIDER_URL=${KEYCLOAK_URL}
1+
export OAUTH_PROVIDER_URL=${KEYCLOAK_URL}
2+
export OAUTH_PROVIDER_CA_CERT=${OAUTH_SERVER_CONFIG_DIR}/ca_keycloak_certificate.pem
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
export KEYCLOAK_URL=https://localhost:8443/realms/test
2-
export OAUTH_PROVIDER_URL=https://localhost:8443/realms/test
3-
export OAUTH_PROVIDER_CA_CERT=selenium/test/oauth/keycloak/ca_keycloak_certificate.pem
2+
#export OAUTH_PROVIDER_URL=https://localhost:8443/realms/test
3+
export KEYCLOAK_CA_CERT=selenium/test/oauth/keycloak/ca_keycloak_certificate.pem
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#export OAUTH_PROVIDER_URL=https://localhost:9090/realms/test
2+
export PROXY_CA_CERT=selenium/test/oauth/httpd-proxy/ca_httpd-proxy_certificate.pem
3+
export PROXY_URL=https://localhost:9090/realms/test
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
guest:{SHA}NWdeaPS1r3uZXZIFrQ/EOELxZFA=

0 commit comments

Comments
 (0)