Search in sources :

Example 1 with AnyAuthenticationPolicy

use of org.apereo.cas.authentication.policy.AnyAuthenticationPolicy in project cas by apereo.

the class PolicyBasedAuthenticationManagerTests method verifyAuthenticateAnyButTryAllSuccess.

@Test
public void verifyAuthenticateAnyButTryAllSuccess() throws Exception {
    final Map<AuthenticationHandler, PrincipalResolver> map = new HashMap<>();
    map.put(newMockHandler(true), null);
    map.put(newMockHandler(false), null);
    final PolicyBasedAuthenticationManager manager = new PolicyBasedAuthenticationManager(getAuthenticationExecutionPlan(map), mockServicesManager(), new AnyAuthenticationPolicy(true));
    final Authentication auth = manager.authenticate(transaction);
    assertEquals(1, auth.getSuccesses().size());
    assertEquals(1, auth.getFailures().size());
    assertEquals(2, auth.getCredentials().size());
}
Also used : AnyAuthenticationPolicy(org.apereo.cas.authentication.policy.AnyAuthenticationPolicy) PrincipalResolver(org.apereo.cas.authentication.principal.PrincipalResolver) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Test(org.junit.Test)

Aggregations

HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 AnyAuthenticationPolicy (org.apereo.cas.authentication.policy.AnyAuthenticationPolicy)1 PrincipalResolver (org.apereo.cas.authentication.principal.PrincipalResolver)1 Test (org.junit.Test)1