use of org.springframework.binding.message.DefaultMessageContext in project cas by apereo.
the class X509CertificateCredentialsRequestHeaderActionTests method verifyErrorInRequestResultsInError.
@Test
public void verifyErrorInRequestResultsInError() throws Exception {
val context = new MockRequestContext();
val messageContext = (DefaultMessageContext) context.getMessageContext();
messageContext.setMessageSource(mock(MessageSource.class));
val request = new MockHttpServletRequest();
request.addHeader("ssl_client_cert", VALID_CERTIFICATE.getContent());
context.setExternalContext(new ServletExternalContext(new MockServletContext(), request, new MockHttpServletResponse()));
context.getRequestScope().put(REQUEST_ATTRIBUTE_X509_ERROR, "true");
assertEquals(CasWebflowConstants.TRANSITION_ID_ERROR, action.execute(context).getId());
}
use of org.springframework.binding.message.DefaultMessageContext in project cas by apereo.
the class X509CertificateCredentialsNonInteractiveActionTests method verifyBadCertificateError.
@Test
public void verifyBadCertificateError() throws Exception {
val context = new MockRequestContext();
val messageContext = (DefaultMessageContext) context.getMessageContext();
messageContext.setMessageSource(mock(MessageSource.class));
val request = new MockHttpServletRequest();
request.setAttribute(X509CertificateCredentialsNonInteractiveAction.REQUEST_ATTRIBUTE_X509_CERTIFICATE, new X509Certificate[] { new CasX509Certificate(false) });
context.setExternalContext(new ServletExternalContext(new MockServletContext(), request, new MockHttpServletResponse()));
assertEquals(CasWebflowConstants.TRANSITION_ID_AUTHENTICATION_FAILURE, this.action.execute(context).getId());
}
Aggregations