@@ -2,8 +2,8 @@ const { By, Key, until, Builder } = require('selenium-webdriver')
22require ( 'chromedriver' )
33const assert = require ( 'assert' )
44const { 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' )
77
88const LoginPage = require ( '../pageobjects/LoginPage' )
99const OverviewPage = require ( '../pageobjects/OverviewPage' )
@@ -14,20 +14,12 @@ const ConnectionsPage = require('../pageobjects/ConnectionsPage');
1414
1515describe ( 'Given an MQTT 5.0 connection with a qos 0 subscription with zero sessionExpiryInterval' , function ( ) {
1616 let login
17- let queuesAndStreams
17+ let queuesAndStreamsPage
1818 let queuePage
1919 let overview
2020 let captureScreen
2121 let queueName
22- let mqttOptions
2322
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'
3123 let mqttClient
3224
3325 before ( async function ( ) {
@@ -52,30 +44,7 @@ describe('Given an MQTT 5.0 connection with a qos 0 subscription with zero sessi
5244 "x-queue-type" : "quorum"
5345 } )
5446
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 ( ) )
7948 let subscribed = new Promise ( ( resolve , reject ) => {
8049 mqttClient . on ( 'error' , function ( err ) {
8150 reject ( err )
0 commit comments