Skip to content

Commit

Permalink
PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
Avery-Dunn committed Dec 17, 2024
1 parent a0023af commit 7738a72
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ void acquireTokenInteractive_Ciam() {
throw new RuntimeException("Error acquiring token with authCode: " + e.getMessage());
}

IntegrationTestHelper.assertTokenResultNotNull(result, true, true);
IntegrationTestHelper.assertAccessAndIdTokensNotNull(result);
assertEquals(user.getUpn(), result.account().username());
}

Expand All @@ -157,7 +157,7 @@ private void assertAcquireTokenCommon(User user, String authority, String scope)
pca,
scope);

IntegrationTestHelper.assertTokenResultNotNull(result, true, true);
IntegrationTestHelper.assertAccessAndIdTokensNotNull(result);
assertEquals(user.getUpn(), result.account().username());
}

Expand All @@ -174,15 +174,15 @@ private void assertAcquireTokenB2C(User user, String authority) {
}

IAuthenticationResult result = acquireTokenInteractive(user, pca, user.getAppId());
IntegrationTestHelper.assertTokenResultNotNull(result, true, true);
IntegrationTestHelper.assertAccessAndIdTokensNotNull(result);
}

private void assertAcquireTokenInstanceAware(User user) {
PublicClientApplication pca = IntegrationTestHelper.createPublicApp(user.getAppId(), TestConstants.MICROSOFT_AUTHORITY_HOST + user.getTenantID());

IAuthenticationResult result = acquireTokenInteractive_instanceAware(user, pca, cfg.graphDefaultScope());

IntegrationTestHelper.assertTokenResultNotNull(result, true, true);
IntegrationTestHelper.assertAccessAndIdTokensNotNull(result);
assertEquals(user.getUpn(), result.account().username());

//This test is using a client app with the login.microsoftonline.com config to get tokens for a login.microsoftonline.us user,
Expand Down Expand Up @@ -236,7 +236,7 @@ public void afterCacheAccess(ITokenCacheAccessContext iTokenCacheAccessContext)
build();

IAuthenticationResult result = acquireTokenInteractive(user, publicCloudPca, TestConstants.USER_READ_SCOPE);
IntegrationTestHelper.assertTokenResultNotNull(result, true, true);
IntegrationTestHelper.assertAccessAndIdTokensNotNull(result);
assertEquals(user.getHomeUPN(), result.account().username());

publicCloudPca.removeAccount(publicCloudPca.getAccounts().join().iterator().next()).join();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,15 +113,15 @@ public void acquireTokenWithAuthorizationCode_CiamCud() throws Exception {
.build())
.get();

IntegrationTestHelper.assertTokenResultNotNull(result, true, true);
IntegrationTestHelper.assertAccessAndIdTokensNotNull(result);
assertEquals(user.getUpn(), result.account().username());

IAuthenticationResult resultSilent = pca.acquireTokenSilently(SilentParameters
.builder(Collections.singleton("user.read"), result.account())
.build())
.get();

IntegrationTestHelper.assertTokenResultNotNull(result, true, true);
IntegrationTestHelper.assertAccessAndIdTokensNotNull(result);
assertEquals(resultSilent.accessToken(), result.accessToken());
assertEquals(resultSilent.account().username(), result.account().username());
}
Expand All @@ -143,7 +143,7 @@ private void assertAcquireTokenADFS2019(User user) {
authCode,
Collections.singleton(TestConstants.ADFS_SCOPE));

IntegrationTestHelper.assertTokenResultNotNull(result, true, true);
IntegrationTestHelper.assertAccessAndIdTokensNotNull(result);
assertEquals(user.getUpn(), result.account().username());
}

Expand All @@ -157,7 +157,7 @@ private void assertAcquireTokenAAD(User user, Map<String, Set<String>> parameter
authCode,
Collections.singleton(cfg.graphDefaultScope()));

IntegrationTestHelper.assertTokenResultNotNull(result, true, true);
IntegrationTestHelper.assertAccessAndIdTokensNotNull(result);
assertEquals(user.getUpn(), result.account().username());
}

Expand All @@ -180,7 +180,7 @@ private void assertAcquireTokenB2C(User user) {
String authCode = acquireAuthorizationCodeAutomated(user, cca, null);
IAuthenticationResult result = acquireTokenInteractiveB2C(cca, authCode);

IntegrationTestHelper.assertTokenResultNotNull(result, true, true);
IntegrationTestHelper.assertAccessAndIdTokensNotNull(result);
}

private IAuthenticationResult acquireTokenAuthorizationCodeFlow(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ void DeviceCodeFlowADTest(String environment) throws Exception {
.build())
.get();

IntegrationTestHelper.assertTokenResultNotNull(result, true, true);
IntegrationTestHelper.assertAccessAndIdTokensNotNull(result);
}

@Test()
Expand All @@ -73,7 +73,7 @@ void DeviceCodeFlowADFSv2019Test() throws Exception {
.build())
.get();

IntegrationTestHelper.assertTokenResultNotNull(result, true, true);
IntegrationTestHelper.assertAccessAndIdTokensNotNull(result);
}

@Test()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ static PublicClientApplication createPublicApp(String appID, String authority) {
}
}

static void assertTokenResultNotNull(IAuthenticationResult result, boolean checkAccessToken, boolean checkIDToken) {
static void assertAccessAndIdTokensNotNull(IAuthenticationResult result) {
assertNotNull(result);
if (checkAccessToken) assertNotNull(result.accessToken());
if (checkIDToken) assertNotNull(result.idToken());
assertNotNull(result.accessToken());
assertNotNull(result.idToken());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ void acquireTokenWithUsernamePassword_Ciam() throws Exception {
.build())
.get();

IntegrationTestHelper.assertTokenResultNotNull(result, true, true);
IntegrationTestHelper.assertAccessAndIdTokensNotNull(result);
}

private void assertAcquireTokenCommon(User user, String authority, String scope, String appId)
Expand All @@ -125,7 +125,7 @@ private void assertAcquireTokenCommon(User user, String authority, String scope,

.get();

IntegrationTestHelper.assertTokenResultNotNull(result, true, true);
IntegrationTestHelper.assertAccessAndIdTokensNotNull(result);
assertEquals(user.getUpn(), result.account().username());
}

Expand All @@ -148,7 +148,7 @@ void acquireTokenWithUsernamePassword_B2C_CustomAuthority() throws Exception {
.build())
.get();

IntegrationTestHelper.assertTokenResultNotNull(result, true, true);
IntegrationTestHelper.assertAccessAndIdTokensNotNull(result);

IAccount account = pca.getAccounts().join().iterator().next();
SilentParameters.builder(Collections.singleton(TestConstants.B2C_READ_SCOPE), account);
Expand All @@ -158,7 +158,7 @@ void acquireTokenWithUsernamePassword_B2C_CustomAuthority() throws Exception {
.build())
.get();

IntegrationTestHelper.assertTokenResultNotNull(result, true, true);
IntegrationTestHelper.assertAccessAndIdTokensNotNull(result);
}

@Test
Expand All @@ -180,7 +180,7 @@ void acquireTokenWithUsernamePassword_B2C_LoginMicrosoftOnline() throws Exceptio
.build())
.get();

IntegrationTestHelper.assertTokenResultNotNull(result, true, true);
IntegrationTestHelper.assertAccessAndIdTokensNotNull(result);

IAccount account = pca.getAccounts().join().iterator().next();
SilentParameters.builder(Collections.singleton(TestConstants.B2C_READ_SCOPE), account);
Expand All @@ -190,6 +190,6 @@ void acquireTokenWithUsernamePassword_B2C_LoginMicrosoftOnline() throws Exceptio
.build())
.get();

IntegrationTestHelper.assertTokenResultNotNull(result, true, true);
IntegrationTestHelper.assertAccessAndIdTokensNotNull(result);
}
}

0 comments on commit 7738a72

Please sign in to comment.