@@ -369,4 +369,136 @@ final class MSALNativeAuthSignInUsernameEndToEndTests: MSALNativeAuthEndToEndBas
369
369
XCTAssertNotNil ( signInVerifyCodeDelegateSpy. result? . idToken)
370
370
XCTAssertEqual ( signInVerifyCodeDelegateSpy. result? . account. username, username)
371
371
}
372
+
373
+ // Sign In - Verify Custom URL Domain - "https://<tenantName>.ciamlogin.com/<tenantName>.onmicrosoft.com"
374
+ func test_signInCustomSubdomainLongInSuccess( ) async throws {
375
+ throw XCTSkip ( " Retrieving OTP failure " )
376
+
377
+ guard let sut = initialisePublicClientApplication ( clientIdType: . code, customAuthorityURLFormat: . tenantSubdomainLongVersion) , let username = retrieveUsernameForSignInCode ( ) else {
378
+ XCTFail ( " Missing information " )
379
+ return
380
+ }
381
+
382
+ let signInExpectation = expectation ( description: " signing in " )
383
+ let signInDelegateSpy = SignInStartDelegateSpy ( expectation: signInExpectation)
384
+
385
+ sut. signIn ( username: username, correlationId: correlationId, delegate: signInDelegateSpy)
386
+
387
+ await fulfillment ( of: [ signInExpectation] )
388
+
389
+ guard signInDelegateSpy. onSignInCodeRequiredCalled else {
390
+ XCTFail ( " onSignInCodeRequired not called " )
391
+ return
392
+ }
393
+
394
+ XCTAssertNotNil ( signInDelegateSpy. newStateCodeRequired)
395
+ XCTAssertNotNil ( signInDelegateSpy. sentTo)
396
+
397
+ // Now submit the code..
398
+
399
+ guard let code = await retrieveCodeFor ( email: username) else {
400
+ XCTFail ( " OTP code could not be retrieved " )
401
+ return
402
+ }
403
+
404
+ let verifyCodeExpectation = expectation ( description: " verifying code " )
405
+ let signInVerifyCodeDelegateSpy = SignInVerifyCodeDelegateSpy ( expectation: verifyCodeExpectation)
406
+
407
+ signInDelegateSpy. newStateCodeRequired? . submitCode ( code: code, delegate: signInVerifyCodeDelegateSpy)
408
+
409
+ await fulfillment ( of: [ verifyCodeExpectation] )
410
+
411
+ XCTAssertTrue ( signInVerifyCodeDelegateSpy. onSignInCompletedCalled)
412
+ XCTAssertNotNil ( signInVerifyCodeDelegateSpy. result)
413
+ XCTAssertNotNil ( signInVerifyCodeDelegateSpy. result? . idToken)
414
+ XCTAssertEqual ( signInVerifyCodeDelegateSpy. result? . account. username, username)
415
+ }
416
+
417
+ // Sign In - Verify Custom URL Domain - "https://<tenantName>.ciamlogin.com/<tenantId>"
418
+ func test_signInCustomSubdomainIdInSuccess( ) async throws {
419
+ throw XCTSkip ( " Retrieving OTP failure " )
420
+
421
+ guard let sut = initialisePublicClientApplication ( clientIdType: . code, customAuthorityURLFormat: . tenantSubdomainTenantId) , let username = retrieveUsernameForSignInCode ( ) else {
422
+ XCTFail ( " Missing information " )
423
+ return
424
+ }
425
+
426
+ let signInExpectation = expectation ( description: " signing in " )
427
+ let signInDelegateSpy = SignInStartDelegateSpy ( expectation: signInExpectation)
428
+
429
+ sut. signIn ( username: username, correlationId: correlationId, delegate: signInDelegateSpy)
430
+
431
+ await fulfillment ( of: [ signInExpectation] )
432
+
433
+ guard signInDelegateSpy. onSignInCodeRequiredCalled else {
434
+ XCTFail ( " onSignInCodeRequired not called " )
435
+ return
436
+ }
437
+
438
+ XCTAssertNotNil ( signInDelegateSpy. newStateCodeRequired)
439
+ XCTAssertNotNil ( signInDelegateSpy. sentTo)
440
+
441
+ // Now submit the code..
442
+
443
+ guard let code = await retrieveCodeFor ( email: username) else {
444
+ XCTFail ( " OTP code could not be retrieved " )
445
+ return
446
+ }
447
+
448
+ let verifyCodeExpectation = expectation ( description: " verifying code " )
449
+ let signInVerifyCodeDelegateSpy = SignInVerifyCodeDelegateSpy ( expectation: verifyCodeExpectation)
450
+
451
+ signInDelegateSpy. newStateCodeRequired? . submitCode ( code: code, delegate: signInVerifyCodeDelegateSpy)
452
+
453
+ await fulfillment ( of: [ verifyCodeExpectation] )
454
+
455
+ XCTAssertTrue ( signInVerifyCodeDelegateSpy. onSignInCompletedCalled)
456
+ XCTAssertNotNil ( signInVerifyCodeDelegateSpy. result)
457
+ XCTAssertNotNil ( signInVerifyCodeDelegateSpy. result? . idToken)
458
+ XCTAssertEqual ( signInVerifyCodeDelegateSpy. result? . account. username, username)
459
+ }
460
+
461
+ // Sign In - Verify Custom URL Domain - "https://<tenantName>.ciamlogin.com/"
462
+ func test_signInCustomSubdomainShortInSuccess( ) async throws {
463
+ throw XCTSkip ( " Retrieving OTP failure " )
464
+
465
+ guard let sut = initialisePublicClientApplication ( clientIdType: . code, customAuthorityURLFormat: . tenantSubdomainShortVersion) , let username = retrieveUsernameForSignInCode ( ) else {
466
+ XCTFail ( " Missing information " )
467
+ return
468
+ }
469
+
470
+ let signInExpectation = expectation ( description: " signing in " )
471
+ let signInDelegateSpy = SignInStartDelegateSpy ( expectation: signInExpectation)
472
+
473
+ sut. signIn ( username: username, correlationId: correlationId, delegate: signInDelegateSpy)
474
+
475
+ await fulfillment ( of: [ signInExpectation] )
476
+
477
+ guard signInDelegateSpy. onSignInCodeRequiredCalled else {
478
+ XCTFail ( " onSignInCodeRequired not called " )
479
+ return
480
+ }
481
+
482
+ XCTAssertNotNil ( signInDelegateSpy. newStateCodeRequired)
483
+ XCTAssertNotNil ( signInDelegateSpy. sentTo)
484
+
485
+ // Now submit the code..
486
+
487
+ guard let code = await retrieveCodeFor ( email: username) else {
488
+ XCTFail ( " OTP code could not be retrieved " )
489
+ return
490
+ }
491
+
492
+ let verifyCodeExpectation = expectation ( description: " verifying code " )
493
+ let signInVerifyCodeDelegateSpy = SignInVerifyCodeDelegateSpy ( expectation: verifyCodeExpectation)
494
+
495
+ signInDelegateSpy. newStateCodeRequired? . submitCode ( code: code, delegate: signInVerifyCodeDelegateSpy)
496
+
497
+ await fulfillment ( of: [ verifyCodeExpectation] )
498
+
499
+ XCTAssertTrue ( signInVerifyCodeDelegateSpy. onSignInCompletedCalled)
500
+ XCTAssertNotNil ( signInVerifyCodeDelegateSpy. result)
501
+ XCTAssertNotNil ( signInVerifyCodeDelegateSpy. result? . idToken)
502
+ XCTAssertEqual ( signInVerifyCodeDelegateSpy. result? . account. username, username)
503
+ }
372
504
}
0 commit comments