Skip to content

Commit

Permalink
fix application authentication unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
amanda-ariyaratne committed Oct 13, 2024
1 parent 0bc8379 commit 78bc0c4
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public List<LocalClaim> getLocalClaims(int tenantId) throws ClaimMetadataExcepti
List<Claim> localClaims = claims.get(LOCAL_CLAIM_DIALECT_URI);

if (localClaims == null) {
throw new ClaimMetadataException("No local claims found.");
return Collections.emptyList();
}

return localClaims.stream()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,22 @@ public void testAddExternalClaim() throws Exception {

service.addExternalClaim(externalClaim, SUPER_TENANT_DOMAIN_NAME);
verify(unifiedClaimMetadataManager, times(1)).addExternalClaim(any(), anyInt());

when(unifiedClaimMetadataManager.getExternalClaims(anyString(), anyInt()))
.thenReturn(Collections.singletonList(externalClaim));
assertThrows(ClaimMetadataException.class, () -> {
service.addExternalClaim(externalClaim, SUPER_TENANT_DOMAIN_NAME);
});

when(unifiedClaimMetadataManager.isLocalClaimMappedWithinDialect(MAPPED_LOCAL_CLAIM_URI, EXTERNAL_CLAIM_DIALECT_URI,
SUPER_TENANT_ID)).thenReturn(Boolean.TRUE);
assertThrows(ClaimMetadataException.class, () -> {
service.addExternalClaim(externalClaim, SUPER_TENANT_DOMAIN_NAME);
});

assertThrows(ClaimMetadataClientException.class, () -> {
service.addExternalClaim(null, SUPER_TENANT_DOMAIN_NAME);
});
}

@Test(expectedExceptions = ClaimMetadataException.class)
Expand Down Expand Up @@ -271,6 +287,21 @@ public void testRemoveLocalClaim() throws ClaimMetadataException {
});
}

@Test
public void testGetExternalClaims() throws ClaimMetadataException {

service.getExternalClaims(EXTERNAL_CLAIM_DIALECT_URI, SUPER_TENANT_DOMAIN_NAME);
verify(unifiedClaimMetadataManager, times(1)).getExternalClaims(anyString(), anyInt());

assertThrows(ClaimMetadataClientException.class, () -> {
service.getExternalClaims(null, SUPER_TENANT_DOMAIN_NAME);
});

assertThrows(ClaimMetadataClientException.class, () -> {
service.getExternalClaims(LOCAL_CLAIM_DIALECT, null);
});
}

@AfterMethod
public void tearDown() {

Expand Down

0 comments on commit 78bc0c4

Please sign in to comment.