use of org.apereo.cas.ticket.UnsatisfiedAuthenticationPolicyException in project cas by apereo.
the class AuthenticationExceptionHandlerTests method handleUnsatisfiedAuthenticationPolicyExceptionByDefault.
@Test
public void handleUnsatisfiedAuthenticationPolicyExceptionByDefault() {
final AuthenticationExceptionHandler handler = new AuthenticationExceptionHandler();
final MessageContext ctx = mock(MessageContext.class);
final ContextualAuthenticationPolicy<?> policy = new TestContextualAuthenticationPolicy();
final String id = handler.handle(new UnsatisfiedAuthenticationPolicyException(policy), ctx);
assertEquals(id, "UnsatisfiedAuthenticationPolicyException");
final ArgumentCaptor<DefaultMessageResolver> message = ArgumentCaptor.forClass(DefaultMessageResolver.class);
verify(ctx, times(1)).addMessage(message.capture());
assertArrayEquals(new String[] { policy.getCode().get() }, message.getValue().getCodes());
}
Aggregations