Skip to content

Commit

Permalink
Added a test to fail the authentication in AggregateRealmTest
Browse files Browse the repository at this point in the history
  • Loading branch information
sharmaananya29 committed Dec 9, 2024
1 parent f021004 commit 34c90e4
Showing 1 changed file with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,20 @@ public void testAuthenticationOnly() throws Exception {
assertEquals("Expected attribute count.", 0, identityAttributes.size());
}

@Test
public void testAuthenticationFails() throws Exception {
Attributes authenticationAttributes = new MapAttributes();
authenticationAttributes.add("team", 0, "One");

SecurityRealm testRealm = createSecurityRealm(false, authenticationAttributes, null, new Attributes[] { null });
RealmIdentity identity = testRealm.getRealmIdentity(new NamePrincipal("invalid_principal"));

assertFalse("Identity should not exist", identity.exists());

Attributes identityAttributes = identity.getAuthorizationIdentity().getAttributes();
assertEquals("Expected no attributes due to authentication failure.", 0, identityAttributes.size());
}

@Test
public void testAuthorizationOnly() throws Exception {
Attributes authorizationAttributes = new MapAttributes();
Expand Down

0 comments on commit 34c90e4

Please sign in to comment.