Skip to content

Commit 06bd98d

Browse files
Renconcile changes from tanzu rabbitmq
1 parent 5613760 commit 06bd98d

21 files changed

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

selenium/bin/components/forward-proxy

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
2+
HTTPD_DOCKER_IMAGE=httpd:latest
3+
4+
ensure_forward-proxy() {
5+
if docker ps | grep forward-proxy &> /dev/null; then
6+
print "forward-proxy already running ..."
7+
else
8+
start_forward-proxy
9+
fi
10+
}
11+
init_forward-proxy() {
12+
HTTPD_CONFIG_DIR=${TEST_CONFIG_DIR}/forward-proxy
13+
PROXY_HOSTNAME=forward-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+
}
22+
23+
start_forward-proxy() {
24+
begin "Starting forward-proxy ..."
25+
26+
init_forward-proxy
27+
kill_container_if_exist forward-proxy
28+
29+
MOUNT_HTTPD_CONFIG_DIR=$CONF_DIR/httpd
30+
31+
mkdir -p $MOUNT_HTTPD_CONFIG_DIR
32+
${BIN_DIR}/gen-httpd-conf ${HTTPD_CONFIG_DIR} $ENV_FILE $MOUNT_HTTPD_CONFIG_DIR/httpd.conf
33+
print "> EFFECTIVE HTTPD_CONFIG_FILE: $MOUNT_HTTPD_CONFIG_DIR/httpd.conf"
34+
cp ${HTTPD_CONFIG_DIR}/.htpasswd $MOUNT_HTTPD_CONFIG_DIR
35+
36+
docker run \
37+
--detach \
38+
--name forward-proxy \
39+
--net ${DOCKER_NETWORK} \
40+
--publish 9092:9092 \
41+
--mount "type=bind,source=${MOUNT_HTTPD_CONFIG_DIR},target=/usr/local/apache2/conf" \
42+
${HTTPD_DOCKER_IMAGE}
43+
44+
#wait_for_url $OAUTH_PROVIDER_URL ${FORWARD_PROXY_URL}
45+
wait_for_message forward-proxy "initializing worker proxy:forward local"
46+
end "forward-proxy is ready"
47+
}

selenium/bin/components/keycloak

+3-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ ensure_keycloak() {
1212
init_keycloak() {
1313
KEYCLOAK_CONFIG_PATH=${KEYCLOAK_CONFIG_PATH:-oauth/keycloak}
1414
KEYCLOAK_CONFIG_DIR=$(realpath ${TEST_DIR}/${KEYCLOAK_CONFIG_PATH})
15-
KEYCLOAK_URL=${OAUTH_PROVIDER_URL}
15+
KEYCLOAK_URL=${KEYCLOAK_URL:-OAUTH_PROVIDER_URL}
1616

1717
print "> KEYCLOAK_CONFIG_DIR: ${KEYCLOAK_CONFIG_DIR}"
1818
print "> KEYCLOAK_URL: ${KEYCLOAK_URL}"
@@ -42,8 +42,9 @@ start_keycloak() {
4242
--publish 8443:8443 \
4343
--env KEYCLOAK_ADMIN=admin \
4444
--env KEYCLOAK_ADMIN_PASSWORD=admin \
45+
--env QUARKUS_HTTP_ACCESS_LOG_ENABLED=true \
4546
-v ${MOUNT_KEYCLOAK_CONF_DIR}:/opt/keycloak/data/import/ \
46-
${KEYCLOAK_DOCKER_IMAGE} start-dev --import-realm \
47+
${KEYCLOAK_DOCKER_IMAGE} start-dev --import-realm --log-level=INFO \
4748
--https-certificate-file=/opt/keycloak/data/import/server_keycloak_certificate.pem \
4849
--https-certificate-key-file=/opt/keycloak/data/import/server_keycloak_key.pem
4950

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

selenium/bin/components/rabbitmq

+2-3
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ start_docker_cluster_rabbitmq() {
9595
kill_container_if_exist rabbitmq1
9696
kill_container_if_exist rabbitmq2
9797

98-
mkdir -p $CONF_DIR/rabbitmq
98+
mkdir -pv $CONF_DIR/rabbitmq/conf.d/
9999

100100
RABBITMQ_TEST_DIR="/var/rabbitmq" ${BIN_DIR}/gen-rabbitmq-conf ${RABBITMQ_CONFIG_DIR} $ENV_FILE $CONF_DIR/rabbitmq/rabbitmq.conf
101101
print "> EFFECTIVE RABBITMQ_CONFIG_FILE: $CONF_DIR/rabbitmq/rabbitmq.conf"
@@ -109,7 +109,6 @@ start_docker_cluster_rabbitmq() {
109109
fi
110110
fi
111111
if [ -f ${RABBITMQ_CONFIG_DIR}/logging.conf ]; then
112-
mkdir -p $CONF_DIR/rabbitmq/conf.d/
113112
cp ${RABBITMQ_CONFIG_DIR}/logging.conf $CONF_DIR/rabbitmq/conf.d/
114113
fi
115114
if [ -f ${RABBITMQ_CONFIG_DIR}/enabled_plugins ]; then
@@ -187,7 +186,7 @@ start_docker_rabbitmq() {
187186
-v $CONF_DIR/rabbitmq/imports:/var/rabbitmq/imports \
188187
-v ${TEST_DIR}:/config \
189188
${RABBITMQ_DOCKER_IMAGE}
190-
189+
191190
wait_for_message rabbitmq "Server startup complete"
192191
end "RabbitMQ ready"
193192
}

selenium/bin/suite_template

+35-8
Original file line numberDiff line numberDiff line change
@@ -218,20 +218,37 @@ wait_for_oidc_endpoint_docker() {
218218
calculate_rabbitmq_url() {
219219
echo "${RABBITMQ_SCHEME:-http}://$1${PUBLIC_RABBITMQ_PATH:-$RABBITMQ_PATH}"
220220
}
221-
221+
calculate_forward_proxy_url() {
222+
PROXIED_URL=$1
223+
PROXY_HOSTNAME=$2
224+
PROXY_PORT=$3
225+
SCHEME=$(echo "$PROXIED_URL" | cut -d: -f1)
226+
PATH=$(echo "$PROXIED_URL" | cut -d/ -f4-)
227+
echo "$SCHEME://$PROXY_HOSTNAME:$PROXY_PORT/$PATH"
228+
}
222229
wait_for_url() {
223230
BASE_URL=$1
224231
if [[ $BASE_URL == *"localhost"** ]]; then
225-
wait_for_url_local $BASE_URL
232+
wait_for_url_local $@
226233
else
227-
wait_for_url_docker $BASE_URL
234+
wait_for_url_docker $@
228235
fi
229236
}
230237
wait_for_url_local() {
231238
url=$1
239+
proxy=${2:-none}
240+
proxy_user=${3:-none}
241+
proxy_pass=$4
242+
curl_args="-L -f -v"
232243
max_retry=10
233244
counter=0
234-
until (curl -L -f -v $url >/dev/null 2>&1)
245+
if [[ "$proxy" != "none" && "$proxy" != "" ]]; then
246+
curl_args="--proxy ${proxy} ${curl_args}"
247+
fi
248+
if [[ "$proxy_user" != "none" && "$proxy_user" != "" ]]; then
249+
curl_args="--proxy-user ${proxy_user}:${proxy_pass} ${curl_args}"
250+
fi
251+
until (curl $curl_args $url >/dev/null 2>&1)
235252
do
236253
print "Waiting for $url to start (local)"
237254
sleep 5
@@ -242,9 +259,19 @@ wait_for_url_local() {
242259
}
243260
wait_for_url_docker() {
244261
url=$1
262+
proxy=${2:-none}
263+
proxy_user=${3:-none}
264+
proxy_pass=$4
245265
max_retry=10
246266
counter=0
247-
until (docker run --net ${DOCKER_NETWORK} --rm curlimages/curl:7.85.0 -L -f -v $url >/dev/null 2>&1)
267+
curl_args="-L -f -v"
268+
if [[ "$proxy" != "none" && "$proxy" != "" ]]; then
269+
curl_args="--proxy ${proxy} ${curl_args}"
270+
fi
271+
if [[ "$proxy_user" != "none" && "$proxy_user" != "" ]]; then
272+
curl_args="--proxy-user ${proxy_user}:${proxy_pass} ${curl_args}"
273+
fi
274+
until (docker run --net ${DOCKER_NETWORK} --rm curlimages/curl:7.85.0 $curl_args $url >/dev/null 2>&1)
248275
do
249276
print "Waiting for $url to start (docker)"
250277
sleep 5
@@ -377,7 +404,8 @@ profiles_with_local_or_docker() {
377404
generate_env_file() {
378405
begin "Generating env file ..."
379406
mkdir -p $CONF_DIR
380-
${BIN_DIR}/gen-env-file $TEST_CONFIG_DIR $ENV_FILE
407+
${BIN_DIR}/gen-env-file $TEST_CONFIG_DIR ${ENV_FILE}.tmp
408+
grep -v '^#' ${ENV_FILE}.tmp > $ENV_FILE
381409
source $ENV_FILE
382410
end "Finished generating env file."
383411
}
@@ -560,7 +588,7 @@ run_on_docker_with() {
560588
build_mocha_image
561589
start_selenium
562590

563-
trap teardown_components EXIT
591+
trap "teardown_components" EXIT
564592

565593
start_components
566594
test
@@ -641,7 +669,6 @@ start_components() {
641669
$start
642670
done
643671
}
644-
645672
teardown_components() {
646673
skip_rabbitmq=${1:-false}
647674

selenium/test/basic-auth/ac-management.js

+6-9
Original file line numberDiff line numberDiff line change
@@ -27,35 +27,32 @@ describe('management user with vhosts permissions', function () {
2727
it('can access overview tab', async function () {
2828
await overview.clickOnOverviewTab()
2929
await overview.waitForOverviewTab()
30-
assert.ok(!await overview.isPopupWarningDisplayed())
30+
assert.ok(await overview.isPopupWarningNotDisplayed())
3131
})
3232
it('can access connections tab', async function () {
3333
await overview.clickOnConnectionsTab()
3434
await overview.waitForConnectionsTab()
35-
assert.ok(!await overview.isPopupWarningDisplayed())
35+
assert.ok(await overview.isPopupWarningNotDisplayed())
3636
})
3737
it('can access channels tab', async function () {
3838
await overview.clickOnChannelsTab()
3939
await overview.waitForChannelsTab()
40-
assert.ok(!await overview.isPopupWarningDisplayed())
40+
assert.ok(await overview.isPopupWarningNotDisplayed())
4141
})
4242
it('can access exchanges tab', async function () {
4343
await overview.clickOnExchangesTab()
4444
await overview.waitForExchangesTab()
45-
assert.ok(!await overview.isPopupWarningDisplayed())
45+
assert.ok(await overview.isPopupWarningNotDisplayed())
4646
})
4747
it('can access queues and streams tab', async function () {
4848
await overview.clickOnQueuesTab()
4949
await overview.waitForQueuesTab()
50-
assert.ok(!await overview.isPopupWarningDisplayed())
50+
assert.ok(await overview.isPopupWarningNotDisplayed())
5151
})
5252
it('can access limited options in admin tab', async function () {
53-
console.log("before clickOnAdminTab")
5453
await overview.clickOnAdminTab()
55-
console.log("before waitForAdminTab")
5654
await overview.waitForAdminTab()
57-
console.log("after waitForAdminTab")
58-
assert.ok(!await overview.isPopupWarningDisplayed())
55+
assert.ok(await overview.isPopupWarningNotDisplayed())
5956
})
6057

6158
it('cannot add/update user limits', async function () {

selenium/test/basic-auth/unauthorized.js

+2-4
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ describe('An user without management tag', function () {
1919
overview = new OverviewPage(driver)
2020
captureScreen = captureScreensFor(driver, __filename)
2121

22-
//assert.ok(!await login.isPopupWarningDisplayed())
2322
await login.login('rabbit_no_management', 'guest')
2423
})
2524

@@ -44,9 +43,8 @@ describe('An user without management tag', function () {
4443
})
4544

4645
it('should close popup warning', async function(){
47-
await delay(1000)
48-
const visible = await login.isPopupWarningDisplayed()
49-
assert.ok(!visible)
46+
await delay(1000)
47+
assert.ok(await login.isPopupWarningNotDisplayed())
5048
})
5149

5250
})
+1-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
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 KEYCLOAK_CA_CERT=/config/oauth/keycloak/ca_keycloak_certificate.pem
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=${KEYCLOAK_CA_CERT}
+2-2
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=${KEYCLOAK_URL}
3+
export KEYCLOAK_CA_CERT=selenium/test/oauth/keycloak/ca_keycloak_certificate.pem

selenium/test/oauth/imports/users.json

+3
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@
5656
"vhosts": [
5757
{
5858
"name": "/"
59+
},
60+
{
61+
"name": "other"
5962
}
6063
],
6164
"permissions": [
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# uaa requires a secret in order to renew tokens
2-
management.oauth_provider_url = ${KEYCLOAK_URL}
2+
#management.oauth_provider_url = ${KEYCLOAK_URL}
33
management.oauth_authorization_endpoint_params.resource = rabbitmq
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
auth_oauth2.issuer = ${OAUTH_PROVIDER_URL}
2-
auth_oauth2.https.cacertfile = ${OAUTH_PROVIDER_CA_CERT}
1+
auth_oauth2.issuer = ${KEYCLOAK_URL}
2+
auth_oauth2.https.cacertfile = ${KEYCLOAK_CA_CERT}
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
auth_oauth2.issuer = ${OAUTH_PROVIDER_URL}
1+
auth_oauth2.issuer = ${KEYCLOAK_URL}
22
auth_oauth2.https.peer_verification = verify_none
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
1+
# uaa requires a secret in order to renew tokens
2+
management.oauth_client_secret = ${OAUTH_CLIENT_SECRET}
3+
14
# uaa requires a secret in order to renew tokens
25
management.oauth_provider_url = ${UAA_URL}

selenium/test/oauth/rabbitmq.uaa-oauth-provider.conf

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# uaa requires a secret in order to renew tokens
2-
management.oauth_client_secret = ${OAUTH_CLIENT_SECRET}
31

42
# configure static signing keys and the oauth provider used by the plugin
53
auth_oauth2.default_key = ${OAUTH_SIGNING_KEY_ID}

0 commit comments

Comments
 (0)