@@ -2,8 +2,8 @@ const { By, Key, until, Builder } = require('selenium-webdriver')
2
2
require ( 'chromedriver' )
3
3
const assert = require ( 'assert' )
4
4
const { buildDriver, goToHome, goToQueue, captureScreensFor, teardown, doUntil, findTableRow } = require ( '../utils' )
5
- const { createQueue, deleteQueue , getManagementUrl, basicAuthorization } = require ( '../mgt-api' )
6
- const mqtt = require ( 'mqtt' )
5
+ const { createQueue, getManagementUrl, basicAuthorization } = require ( '../mgt-api' )
6
+ const { openConnection , getConnectionOptions } = require ( '../ mqtt' )
7
7
8
8
const LoginPage = require ( '../pageobjects/LoginPage' )
9
9
const OverviewPage = require ( '../pageobjects/OverviewPage' )
@@ -14,20 +14,12 @@ const ConnectionsPage = require('../pageobjects/ConnectionsPage');
14
14
15
15
describe ( 'Given an MQTT 5.0 connection with a qos 0 subscription with zero sessionExpiryInterval' , function ( ) {
16
16
let login
17
- let queuesAndStreams
17
+ let queuesAndStreamsPage
18
18
let queuePage
19
19
let overview
20
20
let captureScreen
21
21
let queueName
22
- let mqttOptions
23
22
24
- let mqttProtocol = process . env . MQTT_PROTOCOL || 'mqtt'
25
- let usemtls = process . env . MQTT_USE_MTLS || false
26
- let rabbit = process . env . RABBITMQ_HOSTNAME || 'localhost'
27
- let mqttUrl = process . env . RABBITMQ_MQTT_URL || "mqtt://" + rabbit + ":1883"
28
- let username = process . env . RABBITMQ_AMQP_USERNAME || 'management'
29
- let password = process . env . RABBITMQ_AMQP_PASSWORD || 'guest'
30
- let client_id = process . env . RABBITMQ_AMQP_USERNAME || 'selenium-client'
31
23
let mqttClient
32
24
33
25
before ( async function ( ) {
@@ -52,30 +44,7 @@ describe('Given an MQTT 5.0 connection with a qos 0 subscription with zero sessi
52
44
"x-queue-type" : "quorum"
53
45
} )
54
46
55
- mqttOptions = {
56
- clientId : client_id ,
57
- protocolId : 'MQTT' ,
58
- protocol : mqttProtocol ,
59
- protocolVersion : 5 ,
60
- keepalive : 10000 ,
61
- clean : true ,
62
- reconnectPeriod : '1000' ,
63
- properties : {
64
- sessionExpiryInterval : 0
65
- }
66
- }
67
- if ( mqttProtocol == 'mqtts' ) {
68
- mqttOptions [ "ca" ] = [ fs . readFileSync ( process . env . RABBITMQ_CERTS + "/ca_rabbitmq_certificate.pem" ) ]
69
- }
70
- if ( usemtls ) {
71
- mqttOptions [ "cert" ] = fs . readFileSync ( process . env . RABBITMQ_CERTS + "/client_rabbitmq_certificate.pem" )
72
- mqttOptions [ "key" ] = fs . readFileSync ( process . env . RABBITMQ_CERTS + "/client_rabbitmq_key.pem" )
73
- } else {
74
- mqttOptions [ "username" ] = username
75
- mqttOptions [ "password" ] = password
76
- }
77
-
78
- mqttClient = mqtt . connect ( mqttUrl , mqttOptions )
47
+ mqttClient = openConnection ( getConnectionOptions ( ) )
79
48
let subscribed = new Promise ( ( resolve , reject ) => {
80
49
mqttClient . on ( 'error' , function ( err ) {
81
50
reject ( err )
0 commit comments