Search in sources :

Example 1 with UnsatisfiedAuthenticationPolicyException

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());
}
Also used : UnsatisfiedAuthenticationPolicyException(org.apereo.cas.ticket.UnsatisfiedAuthenticationPolicyException) DefaultMessageResolver(org.springframework.binding.message.DefaultMessageResolver) MessageContext(org.springframework.binding.message.MessageContext) Test(org.junit.Test)

Aggregations

UnsatisfiedAuthenticationPolicyException (org.apereo.cas.ticket.UnsatisfiedAuthenticationPolicyException)1 Test (org.junit.Test)1 DefaultMessageResolver (org.springframework.binding.message.DefaultMessageResolver)1 MessageContext (org.springframework.binding.message.MessageContext)1