Skip to content

Commit 199c337

Browse files
Modify mqtt test suite to use mtls
1 parent 48bee25 commit 199c337

File tree

3 files changed

+31
-13
lines changed

3 files changed

+31
-13
lines changed
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
authnz-messaging/auth-cache-http-backends.sh
22
authnz-messaging/auth-cache-ldap-backends.sh
3-
authnz-messaging/auth-http-backend.sh
3+
authnz-messaging/auth-http-backend-with-mtls.sh
44
authnz-messaging/auth-http-internal-backends-with-internal.sh
55
authnz-messaging/auth-http-internal-backends.sh
66
authnz-messaging/auth-internal-backend.sh
77
authnz-messaging/auth-internal-mtls-backend.sh
88
authnz-messaging/auth-internal-http-backends.sh
99
authnz-messaging/auth-ldap-backend.sh
10-
authnz-messaging/auth-http-backend.sh

selenium/suites/authnz-messaging/auth-http-backend.sh renamed to selenium/suites/authnz-messaging/auth-http-backend-with-mtls.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
SCRIPT="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
44

55
TEST_CASES_PATH=/authnz-msg-protocols
6-
PROFILES="http-user auth-http auth_backends-http"
6+
PROFILES="internal-user auth-http auth_backends-http auth-mtls"
77

88
source $SCRIPT/../../bin/suite_template
99
runWith mock-auth-backend-http

selenium/test/authnz-msg-protocols/mqtt.js

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,25 @@ describe('Having MQTT protocol enbled and the following auth_backends: ' + backe
2323
let password = process.env.RABBITMQ_AMQP_PASSWORD
2424
let client_id = process.env.RABBITMQ_AMQP_USERNAME || 'selenium-client'
2525

26-
before(function () {
27-
if (backends.includes("http") && username.includes("http")) {
26+
before(function () {
27+
if (backends.includes("http") && (username.includes("http") || usemtls)) {
2828
reset()
29-
expectations.push(expectUser({ "username": username, "password": password, "client_id": client_id, "vhost": "/" }, "allow"))
29+
if (!usemtls) {
30+
console.log("Expect %s %s %s", username, password, client_id)
31+
expectations.push(expectUser({
32+
"username": username,
33+
"password": password,
34+
"client_id": client_id,
35+
"vhost": "/" }, "allow"))
36+
} else {
37+
console.log("Expect (mtls) %s %s", username, client_id)
38+
expectations.push(expectUser({
39+
"username": username,
40+
"client_id": client_id,
41+
"vhost": "/" }, "allow"))
42+
}
3043
expectations.push(expectVhost({ "username": username, "vhost": "/"}, "allow"))
44+
3145
} else if (backends.includes("oauth") && username.includes("oauth")) {
3246
let oauthProviderUrl = process.env.OAUTH_PROVIDER_URL
3347
let oauthClientId = process.env.OAUTH_CLIENT_ID
@@ -58,15 +72,20 @@ describe('Having MQTT protocol enbled and the following auth_backends: ' + backe
5872
}
5973
})
6074

61-
it('can open an MQTT connection', function () {
75+
it('can open an MQTT connection', async function () {
6276
var client = mqtt.connect(mqttUrl, mqttOptions)
63-
client.on('error', function(err) {
64-
assert.fail("Mqtt connection failed due to " + err)
65-
client.end()
66-
})
67-
client.on('connect', function(err) {
68-
client.end()
77+
let done = new Promise((resolve, reject) => {
78+
client.on('error', function(err) {
79+
reject(err)
80+
client.end()
81+
assert.fail("Mqtt connection failed due to " + err)
82+
}),
83+
client.on('connect', function(err) {
84+
resolve("ok")
85+
client.end()
86+
})
6987
})
88+
assert.equal("ok", await done)
7089
})
7190

7291
after(function () {

0 commit comments

Comments
 (0)