Skip to content

Commit 5d79eb0

Browse files
MarcialRosalesmergify[bot]
authored andcommitted
Use tls in oauth providers and rabbitmq
(cherry picked from commit 6bf27a2) # Conflicts: # selenium/bin/gen-env-file # selenium/test/authnz-msg-protocols/env.local # selenium/test/multi-oauth/env.local.devkeycloak # selenium/test/multi-oauth/env.local.prodkeycloak # selenium/test/oauth/env.local.keycloak
1 parent 2c0725f commit 5d79eb0

File tree

66 files changed

+525
-426
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+525
-426
lines changed

.github/workflows/test-authnz.yaml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ on:
2424
- 'deps/rabbitmq_auth_/**'
2525
- 'deps/rabbitmq_mqtt/**'
2626
- 'deps/rabbitmq_management/selenium/full-suite-authnz-messaging'
27-
- 'deps/rabbitmq_management/selenium/suites/authnz-messaging'
28-
- 'deps/rabbitmq_management/selenium/test/authnz-msg-protocols'
27+
- 'deps/rabbitmq_management/selenium/suites/authnz-messaging/**'
28+
- 'deps/rabbitmq_management/selenium/test/authnz-msg-protocols/**'
2929
- .github/workflows/test-authnz.yaml
3030
concurrency:
3131
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
@@ -95,7 +95,9 @@ jobs:
9595
run: |
9696
RABBITMQ_DOCKER_IMAGE=bazel/packaging/docker-image:rabbitmq-amd64 \
9797
${SELENIUM_DIR}/run-suites.sh full-suite-authnz-messaging
98-
98+
mkdir -p /tmp/full-suite-authnz-messaging
99+
mv /tmp/selenium/* /tmp/full-suite-authnz-messaging
100+
99101
- name: Upload Test Artifacts
100102
if: always()
101103
uses: actions/[email protected]

.github/workflows/test-management-ui-for-pr.yaml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,7 @@ jobs:
7575
${SELENIUM_DIR}/run-suites.sh
7676
mkdir -p /tmp/full-suite
7777
mv /tmp/selenium/* /tmp/full-suite
78-
mkdir -p /tmp/full-suite/logs
79-
mv ${SELENIUM_DIR}/logs/* /tmp/full-suite/logs
80-
mkdir -p /tmp/full-suite/screens
81-
mv ${SELENIUM_DIR}/screens/* /tmp/full-suite/screens
82-
78+
8379
- name: Upload Test Artifacts
8480
if: always()
8581
uses: actions/[email protected]

.github/workflows/test-management-ui.yaml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,7 @@ jobs:
9090
ADDON_PROFILES=cluster ${SELENIUM_DIR}/run-suites.sh short-suite-management-ui
9191
mkdir -p /tmp/short-suite
9292
mv /tmp/selenium/* /tmp/short-suite
93-
mkdir -p /tmp/short-suite/logs
94-
mv ${SELENIUM_DIR}/logs/* /tmp/short-suite/logs
95-
mkdir -p /tmp/short-suite/screens
96-
mv ${SELENIUM_DIR}/screens/* /tmp/short-suite/screens
97-
93+
9894
- name: Upload Test Artifacts
9995
if: always()
10096
uses: actions/[email protected]

selenium/.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,10 @@ suites/screens/*
77
test/oauth/*/h2/*.trace.db
88
test/oauth/*/h2/*.lock.db
99
*/target/*
10+
tls-gen
11+
test/*/certs/*.pem
12+
test/*/certs/*.p12
13+
test/*/certs/*.jks
14+
test/*/*/*.pem
15+
test/*/*/*.p12
16+
test/*/*/*.jks

selenium/amqp10-roundtriptest/src/main/java/com/rabbitmq/amqp1_0/RoundTripTest.java

Lines changed: 41 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,45 @@ public class RoundTripTest {
1515
public static String getEnv(String property, String defaultValue) {
1616
return System.getenv(property) == null ? defaultValue : System.getenv(property);
1717
}
18+
public static String getEnv(String property) {
19+
String value = System.getenv(property);
20+
if (value == null) {
21+
throw new IllegalArgumentException("Missing env variable " + property);
22+
}
23+
return value;
24+
}
1825
public static void main(String args[]) throws Exception {
1926
String hostname = getEnv("RABBITMQ_HOSTNAME", "localhost");
2027
String port = getEnv("RABBITMQ_AMQP_PORT", "5672");
2128
String scheme = getEnv("RABBITMQ_AMQP_SCHEME", "amqp");
29+
String uri = scheme + "://" + hostname + ":" + port;
2230
String username = args.length > 0 ? args[0] : getEnv("RABBITMQ_AMQP_USERNAME", "guest");
2331
String password = args.length > 1 ? args[1] : getEnv("RABBITMQ_AMQP_PASSWORD", "guest");
24-
String uri = scheme + "://" + hostname + ":" + port;
32+
33+
boolean usemtls = Boolean.parseBoolean(getEnv("AMQP_USE_MTLS", "false"));
34+
String certsLocation = getEnv("RABBITMQ_CERTS");
35+
36+
if ("amqps".equals(scheme)) {
37+
List<String> connectionParams = new ArrayList<String>();
38+
39+
connectionParams.add("transport.trustStoreLocation=" + certsLocation + "/truststore.jks");
40+
connectionParams.add("transport.trustStorePassword=foobar");
41+
connectionParams.add("transport.verifyHost=true");
42+
connectionParams.add("transport.trustAll=true");
2543

26-
System.out.println("AMQPS Roundrip using uri " + uri);
44+
if (usemtls) {
45+
connectionParams.add("amqp.saslMechanisms=EXTERNAL");
46+
connectionParams.add("transport.keyStoreLocation=" + certsLocation + "/client_rabbitmq.jks");
47+
connectionParams.add("transport.keyStorePassword=foobar");
48+
connectionParams.add("transport.keyAlias=client-rabbitmq-tls");
49+
}
50+
if (!connectionParams.isEmpty()) {
51+
uri = uri + "?" + String.join("&", connectionParams);
52+
System.out.println("Using AMQP URI " + uri);
53+
}
54+
}
55+
56+
assertNotNull(uri);
2757

2858
Hashtable<Object, Object> env = new Hashtable<>();
2959
env.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.qpid.jms.jndi.JmsInitialContextFactory");
@@ -33,12 +63,11 @@ public static void main(String args[]) throws Exception {
3363
env.put("jms.requestTimeout", 5);
3464
javax.naming.Context context = new javax.naming.InitialContext(env);
3565

36-
assertNotNull(uri);
37-
3866
ConnectionFactory factory = (ConnectionFactory) context.lookup("myFactoryLookup");
3967
Destination queue = (Destination) context.lookup("myQueueLookup");
4068

41-
try (Connection connection = factory.createConnection(username, password)) {
69+
try (Connection connection =
70+
createConnection(factory, usemtls, username, password)) {
4271
connection.start();
4372

4473
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
@@ -56,5 +85,12 @@ public static void main(String args[]) throws Exception {
5685

5786
assertEquals(message.getText(), receivedMessage.getText());
5887
}
88+
}
89+
private static Connection createConnection(ConnectionFactory factory,
90+
boolean usemtls, String username, String password) throws jakarta.jms.JMSException {
91+
if (usemtls) {
92+
return factory.createConnection();
93+
}
94+
return factory.createConnection(username, password);
5995
}
6096
}

selenium/bin/components/devkeycloak

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ init_devkeycloak() {
99
print "> DEVKEYCLOAK_CONFIG_DIR: ${DEVKEYCLOAK_CONFIG_DIR}"
1010
print "> DEVKEYCLOAK_URL: ${DEVKEYCLOAK_URL}"
1111
print "> DEVKEYCLOAK_DOCKER_IMAGE: ${KEYCLOAK_DOCKER_IMAGE}"
12+
13+
generate-ca-server-client-kpi devkeycloak $DEVKEYCLOAK_CONFIG_DIR
14+
1215
}
1316
ensure_devkeycloak() {
1417
if docker ps | grep devkeycloak &> /dev/null; then

selenium/bin/components/fakeportal

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
#!/usr/bin/env bash
2+
3+
SCRIPT="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
4+
5+
if [[ ! -z "${DEBUG}" ]]; then
6+
set -x
7+
fi
18

29
ensure_fakeportal() {
310
if docker ps | grep fakeportal &> /dev/null; then
@@ -9,7 +16,7 @@ ensure_fakeportal() {
916

1017
init_fakeportal() {
1118
FAKEPORTAL_URL=${FAKEPORTAL_URL:-http://fakeportal:3000}
12-
FAKEPORTAL_DIR=${SCRIPT}/../fakeportal
19+
FAKEPORTAL_DIR=${SCRIPT}/../../fakeportal
1320
CLIENT_ID="${CLIENT_ID:-rabbit_idp_user}"
1421
CLIENT_SECRET="${CLIENT_SECRET:-rabbit_idp_user}"
1522
RABBITMQ_HOST=${RABBITMQ_HOST:-proxy:9090}
@@ -44,6 +51,8 @@ start_fakeportal() {
4451
--env UAA_URL="${UAA_URL_FOR_FAKEPORTAL}" \
4552
--env CLIENT_ID="${CLIENT_ID}" \
4653
--env CLIENT_SECRET="${CLIENT_SECRET}" \
54+
--env NODE_EXTRA_CA_CERTS=/etc/uaa/ca_uaa_certificate.pem \
55+
-v ${TEST_CONFIG_PATH}/uaa:/etc/uaa \
4756
-v ${FAKEPORTAL_DIR}:/code/fakeportal \
4857
mocha-test:${mocha_test_tag} run fakeportal
4958

selenium/bin/components/fakeproxy

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1+
#!/usr/bin/env bash
12

3+
SCRIPT="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
4+
5+
if [[ ! -z "${DEBUG}" ]]; then
6+
set -x
7+
fi
28

39
ensure_fakeproxy() {
410
if docker ps | grep fakeproxy &> /dev/null; then
@@ -10,7 +16,7 @@ ensure_fakeproxy() {
1016

1117
init_fakeproxy() {
1218
FAKEPROXY_URL=${FAKEPROXY_URL:-http://fakeproxy:9090}
13-
FAKEPROXY_DIR=${SCRIPT}/../fakeportal
19+
FAKEPROXY_DIR=${SCRIPT}/../../fakeportal
1420
CLIENT_ID="${CLIENT_ID:-rabbit_idp_user}"
1521
CLIENT_SECRET="${CLIENT_SECRET:-rabbit_idp_user}"
1622
RABBITMQ_HOST_FOR_FAKEPROXY=${RABBITMQ_HOST_FOR_FAKEPROXY:-rabbitmq:15672}
@@ -43,6 +49,8 @@ start_fakeproxy() {
4349
--env UAA_URL="${UAA_URL_FOR_FAKEPROXY}" \
4450
--env CLIENT_ID="${CLIENT_ID}" \
4551
--env CLIENT_SECRET="${CLIENT_SECRET}" \
52+
--env NODE_EXTRA_CA_CERTS=/etc/uaa/ca_uaa_certificate.pem \
53+
-v ${TEST_CONFIG_PATH}/uaa:/etc/uaa \
4654
-v ${FAKEPROXY_DIR}:/code/fakeportal \
4755
mocha-test:${mocha_test_tag} run fakeproxy
4856

selenium/bin/components/keycloak

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ init_keycloak() {
1717
print "> KEYCLOAK_CONFIG_DIR: ${KEYCLOAK_CONFIG_DIR}"
1818
print "> KEYCLOAK_URL: ${KEYCLOAK_URL}"
1919
print "> KEYCLOAK_DOCKER_IMAGE: ${KEYCLOAK_DOCKER_IMAGE}"
20+
21+
generate-ca-server-client-kpi keycloak $KEYCLOAK_CONFIG_DIR
22+
2023
}
2124
start_keycloak() {
2225
begin "Starting keycloak ..."
@@ -44,7 +47,7 @@ start_keycloak() {
4447
--https-certificate-file=/opt/keycloak/data/import/server_keycloak_certificate.pem \
4548
--https-certificate-key-file=/opt/keycloak/data/import/server_keycloak_key.pem
4649

47-
wait_for_oidc_endpoint keycloak $KEYCLOAK_URL $MOUNT_KEYCLOAK_CONF_DIR/ca_certificate.pem
50+
wait_for_oidc_endpoint keycloak $KEYCLOAK_URL $MOUNT_KEYCLOAK_CONF_DIR/ca_keycloak_certificate.pem
4851
end "Keycloak is ready"
4952

5053
print " Note: If you modify keycloak configuration. Make sure to run the following command to export the configuration."

selenium/bin/components/prodkeycloak

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ init_prodkeycloak() {
1616
print "> PRODKEYCLOAK_CONFIG_DIR: ${PRODKEYCLOAK_CONFIG_DIR}"
1717
print "> PRODKEYCLOAK_URL: ${PRODKEYCLOAK_URL}"
1818
print "> KEYCLOAK_DOCKER_IMAGE: ${KEYCLOAK_DOCKER_IMAGE}"
19+
20+
generate-ca-server-client-kpi prodkeycloak $PRODKEYCLOAK_CONFIG_DIR
21+
1922
}
2023
start_prodkeycloak() {
2124
begin "Starting prodkeycloak ..."

0 commit comments

Comments
 (0)