@@ -284,6 +284,19 @@ final class MQTTNIOv5Tests: XCTestCase {
284
284
try client2. disconnect ( ) . wait ( )
285
285
}
286
286
287
+ func testBadAuthenticationMethod( ) throws {
288
+ let client = self . createClient ( identifier: " testSessionExpiryInterval " )
289
+ defer { XCTAssertNoThrow ( try client. syncShutdownGracefully ( ) ) }
290
+ XCTAssertThrowsError ( _ = try client. v5. connect ( properties: [ . authenticationMethod( " test " ) ] ) . wait ( ) ) { error in
291
+ switch error {
292
+ case MQTTError . reasonError( let reason) :
293
+ XCTAssertEqual ( reason, . badAuthenticationMethod)
294
+ default :
295
+ XCTFail ( " \( error) " )
296
+ }
297
+ }
298
+ }
299
+
287
300
func testInvalidTopicName( ) throws {
288
301
let client = self . createClient ( identifier: " testInvalidTopicName " )
289
302
defer { XCTAssertNoThrow ( try client. syncShutdownGracefully ( ) ) }
@@ -327,6 +340,24 @@ final class MQTTNIOv5Tests: XCTestCase {
327
340
try client. disconnect ( ) . wait ( )
328
341
}
329
342
343
+ func testAuth( ) throws {
344
+ let client = self . createClient ( identifier: " testReauth " )
345
+ defer { XCTAssertNoThrow ( try client. syncShutdownGracefully ( ) ) }
346
+
347
+ _ = try client. v5. connect ( ) . wait ( )
348
+ let authFuture = client. v5. auth ( properties: [ ] ) { _, eventLoop in
349
+ return eventLoop. makeSucceededFuture ( . init( reason: . continueAuthentication, properties: [ ] ) )
350
+ }
351
+ XCTAssertThrowsError ( try authFuture. wait ( ) ) { error in
352
+ switch error {
353
+ case MQTTError . serverClosedConnection:
354
+ break
355
+ default :
356
+ XCTFail ( " \( error) " )
357
+ }
358
+ }
359
+ }
360
+
330
361
func testSubscribeAll( ) throws {
331
362
if ProcessInfo . processInfo. environment [ " CI " ] != nil {
332
363
return
0 commit comments