@@ -113,7 +113,7 @@ describe("publish to node 1, receive from node2", () => {
113113 test ( "synchronously, over Websockets" , async ( ) => {
114114 // Test v4 (3.1.1) and v5 (5.0) simultaneously
115115 const client1 = await mqtt . connectAsync ( "ws://127.0.0.1:8080" , { protocolVersion : 4 } ) ;
116- const client2 = await mqtt . connectAsync ( "ws://127.0.0.1:8081" , { protocolVersion : 5 } ) ;
116+ const client2 = await mqtt . connectAsync ( "ws://127.0.0.1:8081" , { protocolVersion : 5 } ) ;
117117
118118 await client2 . subscribeAsync ( "weather/los_angeles" ) ;
119119
@@ -267,5 +267,27 @@ describe("publish to node 1, receive from node2", () => {
267267
268268 await client1 . endAsync ( ) ;
269269 await client2 . endAsync ( ) ;
270- } ) ;
270+ } ) ,
271+ test ( "ACL" , async ( ) => {
272+ // Can publish to test_topic but not subscribe
273+ const client1 = await mqtt . connectAsync ( "mqtt://localhost:1884" , { protocolVersion : 5 , username : "test_user1" , password : "1234" } ) ;
274+ // Can subscribe to test_topic but not publish
275+ const client2 = await mqtt . connectAsync ( "mqtt://localhost:1884" , { protocolVersion : 5 , username : "test_user2" , password : "1234" } ) ;
276+ // Can do anything anywhere
277+ const client3 = await mqtt . connectAsync ( "mqtt://localhost:1884" , { protocolVersion : 5 } ) ;
278+
279+ await client1 . publishAsync ( "test_topic" , "a test message" ) ;
280+
281+ const client_1_res = await client1 . subscribe ( "test_topic" ) ;
282+ expect ( client_1_res . reasonCode ) . toBe ( 1 ) ;
283+
284+ await client2 . subscribe ( "test_topic" ) ;
285+
286+ const [ topic , message ] = await events . once ( client2 , 'message' ) ;
287+
288+ expect ( topic . toString ( ) ) . toBe ( "test_topic" ) ;
289+ expect ( message . toString ( ) ) . toBe ( "a test message" ) ;
290+
291+ } )
292+ ;
271293} ) ;
0 commit comments