1+ const fs = require ( 'fs' )
12const assert = require ( 'assert' )
23const { tokenFor, openIdConfiguration } = require ( '../utils' )
34const { reset, expectUser, expectVhost, expectResource, allow, verifyAll } = require ( '../mock_http_backend' )
@@ -14,13 +15,14 @@ for (const element of profiles.split(" ")) {
1415describe ( 'Having MQTT protocol enbled and the following auth_backends: ' + backends , function ( ) {
1516 let mqttOptions
1617 let expectations = [ ]
18+ let mqttProtocol = process . env . MQTT_PROTOCOL || 'mqtt'
1719 let rabbit = process . env . RABBITMQ_HOSTNAME || 'localhost'
1820 let mqttUrl = process . env . RABBITMQ_MQTT_URL || "mqtt://" + rabbit + ":1883"
1921 let username = process . env . RABBITMQ_AMQP_USERNAME
2022 let password = process . env . RABBITMQ_AMQP_PASSWORD
2123 let client_id = process . env . RABBITMQ_AMQP_CLIENT_ID || 'selenium-client'
2224
23- console . log ( "RABBITMQ_TEST_DIR : " + process . env . RABBITMQ_TEST_DIR )
25+ console . log ( "RABBITMQ_CERTS : " + process . env . RABBITMQ_CERTS )
2426
2527 before ( function ( ) {
2628 if ( backends . includes ( "http" ) && username . includes ( "http" ) ) {
@@ -39,13 +41,19 @@ describe('Having MQTT protocol enbled and the following auth_backends: ' + backe
3941 mqttOptions = {
4042 clientId : client_id ,
4143 protocolId : 'MQTT' ,
44+ protocol : mqttProtocol ,
4245 protocolVersion : 4 ,
4346 keepalive : 10000 ,
4447 clean : false ,
4548 reconnectPeriod : '1000' ,
4649 username : username ,
4750 password : password
4851 }
52+ if ( mqttProtocol == 'mqtts' ) {
53+ mqttOptions [ "ca" ] = [ fs . readFileSync ( process . env . RABBITMQ_CERTS + "/ca_rabbitmq_certificate.pem" ) ]
54+ mqttOptions [ "cert" ] = fs . readFileSync ( process . env . RABBITMQ_CERTS + "/client_rabbitmq_certificate.pem" )
55+ mqttOptions [ "key" ] = fs . readFileSync ( process . env . RABBITMQ_CERTS + "/client_rabbitmq_key.pem" )
56+ }
4957 } )
5058
5159 it ( 'can open an MQTT connection' , function ( ) {
0 commit comments