-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Log error if Okta and DB role claims unequal (#8182)
- Loading branch information
Showing
5 changed files
with
43 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -125,9 +125,14 @@ void checkOrgRoleClaimsEquality_withIdenticalOrgRoleClaims_inDifferentOrder_isTr | |
OrganizationRoleClaimsTestUtils.DB_ORG_EXTERNAL_ID, | ||
Set.of(OrganizationRole.ALL_FACILITIES, OrganizationRole.ADMIN)); | ||
|
||
String username = "[email protected]"; | ||
ApiUser mockApiUser = mock(ApiUser.class); | ||
when(_apiUserRepoSpy.findByLoginEmail(username)).thenReturn(Optional.of(mockApiUser)); | ||
assertTrue( | ||
_service.checkOrgRoleClaimsEquality( | ||
List.of(secondOktaClaim, firstOktaClaim), List.of(firstDbClaim, secondDbClaim))); | ||
List.of(secondOktaClaim, firstOktaClaim), | ||
List.of(firstDbClaim, secondDbClaim), | ||
"[email protected]")); | ||
} | ||
|
||
@Test | ||
|
@@ -146,7 +151,10 @@ void checkOrgRoleClaimsEquality_withDifferentRoleOrder_isTrue() { | |
OrganizationRoleClaimsTestUtils.OKTA_ORG_EXTERNAL_ID, | ||
Set.of(OrganizationRole.ALL_FACILITIES, OrganizationRole.USER)); | ||
|
||
assertTrue(_service.checkOrgRoleClaimsEquality(List.of(oktaClaim), List.of(dbClaim))); | ||
String username = "[email protected]"; | ||
ApiUser mockApiUser = mock(ApiUser.class); | ||
when(_apiUserRepoSpy.findByLoginEmail(username)).thenReturn(Optional.of(mockApiUser)); | ||
assertTrue(_service.checkOrgRoleClaimsEquality(List.of(oktaClaim), List.of(dbClaim), username)); | ||
} | ||
|
||
@Test | ||
|
@@ -164,7 +172,11 @@ void checkOrgRoleClaimsEquality_withDifferentOrgClaims_isFalse() { | |
|
||
Mockito.reset(_apiUserRepoSpy); | ||
|
||
assertFalse(_service.checkOrgRoleClaimsEquality(List.of(oktaClaim), List.of(dbClaim))); | ||
String username = "[email protected]"; | ||
ApiUser mockApiUser = mock(ApiUser.class); | ||
when(_apiUserRepoSpy.findByLoginEmail(username)).thenReturn(Optional.of(mockApiUser)); | ||
assertFalse( | ||
_service.checkOrgRoleClaimsEquality(List.of(oktaClaim), List.of(dbClaim), username)); | ||
verify(_apiUserRepoSpy, times(1)).findByLoginEmail(any()); | ||
} | ||
|
||
|
@@ -176,7 +188,10 @@ void checkOrgRoleClaimsEquality_withDifferentOrgClaimsSize_isFalse() { | |
OrganizationRoleClaimsTestUtils.OKTA_FACILITY_NAMES, | ||
Set.of(OrganizationRole.NO_ACCESS, OrganizationRole.USER)); | ||
|
||
assertFalse(_service.checkOrgRoleClaimsEquality(List.of(oktaClaim), List.of())); | ||
String username = "[email protected]"; | ||
ApiUser mockApiUser = mock(ApiUser.class); | ||
when(_apiUserRepoSpy.findByLoginEmail(username)).thenReturn(Optional.of(mockApiUser)); | ||
assertFalse(_service.checkOrgRoleClaimsEquality(List.of(oktaClaim), List.of(), username)); | ||
} | ||
|
||
private OrganizationRoleClaims createClaimsForCreatedOrg( | ||
|