use of org.apereo.cas.authentication.policy.RequiredAuthenticationHandlerAuthenticationPolicy in project cas by apereo.
the class DefaultAuthenticationManagerTests method verifyAuthenticateRequiredHandlerSuccess.
@Test
public void verifyAuthenticateRequiredHandlerSuccess() {
val map = new LinkedHashMap<AuthenticationHandler, PrincipalResolver>();
map.put(newMockHandler(HANDLER_A, true), null);
map.put(newMockHandler(HANDLER_B, false), null);
val authenticationExecutionPlan = getAuthenticationExecutionPlan(map);
authenticationExecutionPlan.registerAuthenticationPolicy(new RequiredAuthenticationHandlerAuthenticationPolicy(HANDLER_A));
val manager = new DefaultAuthenticationManager(authenticationExecutionPlan, false, applicationContext);
val auth = manager.authenticate(transaction);
assertEquals(1, auth.getSuccesses().size());
assertEquals(2, auth.getCredentials().size());
}
use of org.apereo.cas.authentication.policy.RequiredAuthenticationHandlerAuthenticationPolicy in project cas by apereo.
the class DefaultAuthenticationManagerTests method verifyAuthenticateRequiredHandlerFailure.
@Test
public void verifyAuthenticateRequiredHandlerFailure() {
val map = new LinkedHashMap<AuthenticationHandler, PrincipalResolver>();
map.put(newMockHandler(HANDLER_A, true), null);
map.put(newMockHandler(HANDLER_B, false), null);
val authenticationExecutionPlan = getAuthenticationExecutionPlan(map);
authenticationExecutionPlan.registerAuthenticationPolicy(new RequiredAuthenticationHandlerAuthenticationPolicy(HANDLER_B));
val manager = new DefaultAuthenticationManager(authenticationExecutionPlan, false, applicationContext);
assertThrows(AuthenticationException.class, () -> manager.authenticate(transaction));
}
Aggregations