@@ -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