diff --git a/auth/realm/base/src/test/java/org/wildfly/security/auth/realm/AggregateRealmTest.java b/auth/realm/base/src/test/java/org/wildfly/security/auth/realm/AggregateRealmTest.java index 2038b48c48..238fd6911f 100644 --- a/auth/realm/base/src/test/java/org/wildfly/security/auth/realm/AggregateRealmTest.java +++ b/auth/realm/base/src/test/java/org/wildfly/security/auth/realm/AggregateRealmTest.java @@ -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();