Skip to content

Commit

Permalink
Merge pull request #389 from AzureAD/oldalton/guest_user_test_fixes
Browse files Browse the repository at this point in the history
Fixed guest user tests
  • Loading branch information
oldalton authored Oct 30, 2018
2 parents af5f54f + 1a9f675 commit 68bab98
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 8 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
## [0.2.1] - 2018-09-27
## [0.2.1] - 2018-10-29
### Added
- Fix clang analyzer issues.
- WKWebView drops network connection if device got locked on iOS 12. It is by design and not configurable.
- Improved schema compatibility with other MSAL/ADAL SDKs
- Optimize silent requests

## [0.2.0] - 2018-09-18
### Added
Expand Down
52 changes: 48 additions & 4 deletions MSAL/test/automation/tests/interactive/MSALGuestUserTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ - (void)testInteractiveAndSilentAADLogin_withNonConvergedApp_withPromptAlways_no
request.authority = [NSString stringWithFormat:@"https://login.microsoftonline.com/%@", self.primaryAccount.targetTenantId];

// 1. Run interactive in the guest tenant
NSString *homeAccountId = [self runSharedADFSInteractiveLoginWithRequest:request closeResultView:NO];
NSString *homeAccountId = [self runSharedGuestInteractiveLoginWithRequest:request closeResultView:NO];
NSString *resultTenantId = [self resultDictionary][@"tenantId"];
XCTAssertEqualObjects(resultTenantId, self.primaryAccount.targetTenantId);
XCTAssertNotNil(homeAccountId);
Expand Down Expand Up @@ -86,7 +86,7 @@ - (void)testInteractiveAndSilentAADLogin_withNonConvergedApp_withPromptAlways_no
homeRequest.authority = [NSString stringWithFormat:@"https://login.microsoftonline.com/%@", self.primaryAccount.homeTenantId];

// 1. Run interactive in the home tenant
NSString *homeAccountId = [self runSharedADFSInteractiveLoginWithRequest:homeRequest closeResultView:NO];
NSString *homeAccountId = [self runSharedGuestInteractiveLoginWithRequest:homeRequest closeResultView:NO];
NSString *resultTenantId = [self resultDictionary][@"tenantId"];
XCTAssertEqualObjects(resultTenantId, self.primaryAccount.homeTenantId);
XCTAssertNotNil(homeAccountId);
Expand Down Expand Up @@ -124,7 +124,7 @@ - (void)testInteractiveAndSilentAADLogin_withConvergedApp_withPromptAlways_noLog
guestRequest.authority = [NSString stringWithFormat:@"https://login.microsoftonline.com/%@", self.primaryAccount.targetTenantId];

// 1. Run interactive in the guest tenant
NSString *homeAccountId = [self runSharedADFSInteractiveLoginWithRequest:guestRequest closeResultView:NO];
NSString *homeAccountId = [self runSharedGuestInteractiveLoginWithRequest:guestRequest closeResultView:NO];
NSString *resultTenantId = [self resultDictionary][@"tenantId"];
XCTAssertEqualObjects(resultTenantId, self.primaryAccount.targetTenantId);
XCTAssertNotNil(homeAccountId);
Expand All @@ -142,7 +142,7 @@ - (void)testInteractiveAndSilentAADLogin_withConvergedApp_withPromptAlways_noLog
// TODO: lab doesn't return correct home object ID at the moment, need to follow up on that!
homeRequest.testAccount.homeObjectId = [[homeAccountId componentsSeparatedByString:@"."] firstObject];
homeRequest.testAccount.targetTenantId = self.primaryAccount.homeTenantId;
[self runSharedADFSInteractiveLoginWithRequest:homeRequest closeResultView:YES];
[self runSharedGuestInteractiveLoginWithRequest:homeRequest closeResultView:YES];

// 3. Run silent for the guest tenant
guestRequest.accountIdentifier = homeAccountId;
Expand All @@ -159,4 +159,48 @@ - (void)testInteractiveAndSilentAADLogin_withConvergedApp_withPromptAlways_noLog
[self runSharedSilentAADLoginWithTestRequest:homeRequest];
}

- (NSString *)runSharedGuestInteractiveLoginWithRequest:(MSALTestRequest *)request
closeResultView:(BOOL)closeResultView
{
// 1. Do interactive login
NSDictionary *config = [self configWithTestRequest:request];
[self acquireToken:config];

[self acceptAuthSessionDialogIfNecessary:request];

if (!request.loginHint)
{
[self aadEnterEmail];
}

[self enterGuestUsername];
[self enterGuestPassword];
[self acceptMSSTSConsentIfNecessary:@"Accept" embeddedWebView:request.usesEmbeddedWebView];

NSString *homeAccountId = [self runSharedResultAssertionWithTestRequest:request guestTenantScenario:NO];

if (closeResultView)
{
[self closeResultView];
}

return homeAccountId;
}

- (void)enterGuestUsername
{
XCUIElement *passwordTextField = [self.testApp.textFields elementBoundByIndex:0];
[self waitForElement:passwordTextField];
[self tapElementAndWaitForKeyboardToAppear:passwordTextField];
[passwordTextField typeText:[NSString stringWithFormat:@"%@\n", self.primaryAccount.username]];
}

- (void)enterGuestPassword
{
XCUIElement *passwordTextField = [self.testApp.secureTextFields elementBoundByIndex:0];
[self waitForElement:passwordTextField];
[self tapElementAndWaitForKeyboardToAppear:passwordTextField];
[passwordTextField typeText:[NSString stringWithFormat:@"%@\n", self.primaryAccount.password]];
}

@end
3 changes: 0 additions & 3 deletions MSAL/test/automation/tests/interactive/MSALShibUITests.m
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,6 @@ - (void)testInteractiveShibLogin_withConvergedApp_withPromptAlways_withLoginHint
// 1. Run interactive
NSString *homeAccountId = [self runSharedShibbolethInteractiveLoginWithRequest:request];
XCTAssertNotNil(homeAccountId);

// 2. Run UI appears step
[self runSharedAuthUIAppearsStepWithTestRequest:request];
}

- (void)testInteractiveShibLogin_withConvergedApp_withPromptAlways_withLoginHint_andPassedInWebView
Expand Down

0 comments on commit 68bab98

Please sign in to comment.