use of org.springframework.webflow.test.MockRequestContext in project cas by apereo.
the class X509CertificateCredentialsNonInteractiveActionTests method verifyCredentialsResultsInSuccess.
@Test
public void verifyCredentialsResultsInSuccess() throws Exception {
final MockRequestContext context = new MockRequestContext();
final MockHttpServletRequest request = new MockHttpServletRequest();
request.setAttribute("javax.servlet.request.X509Certificate", new X509Certificate[] { VALID_CERTIFICATE });
context.setExternalContext(new ServletExternalContext(new MockServletContext(), request, new MockHttpServletResponse()));
assertEquals("success", this.action.execute(context).getId());
}
use of org.springframework.webflow.test.MockRequestContext in project cas by apereo.
the class PrincipalFromRequestRemoteUserNonInteractiveCredentialsActionTests method verifyRemoteUserDoesntExists.
@Test
public void verifyRemoteUserDoesntExists() throws Exception {
final MockRequestContext context = new MockRequestContext();
context.setExternalContext(new ServletExternalContext(new MockServletContext(), new MockHttpServletRequest(), new MockHttpServletResponse()));
assertEquals("error", this.action.execute(context).getId());
}
use of org.springframework.webflow.test.MockRequestContext in project cas by apereo.
the class PrincipalFromRequestUserPrincipalNonInteractiveCredentialsActionTests method verifyRemoteUserDoesntExists.
@Test
public void verifyRemoteUserDoesntExists() throws Exception {
final MockRequestContext context = new MockRequestContext();
context.setExternalContext(new ServletExternalContext(new MockServletContext(), new MockHttpServletRequest(), new MockHttpServletResponse()));
Assert.assertEquals("error", this.action.execute(context).getId());
}
use of org.springframework.webflow.test.MockRequestContext in project cas by apereo.
the class CasWebflowContextConfigurationTests method getMockRequestContext.
private RequestContext getMockRequestContext() {
final MockRequestContext ctx = new MockRequestContext();
final MockHttpServletRequest request = new MockHttpServletRequest();
final MockHttpServletResponse response = new MockHttpServletResponse();
final MockServletContext sCtx = new MockServletContext();
ctx.setExternalContext(new ServletExternalContext(sCtx, request, response));
return ctx;
}
use of org.springframework.webflow.test.MockRequestContext in project cas by apereo.
the class InspektrThrottledSubmissionByIpAddressAndUsernameHandlerInterceptorAdapterTests method loginUnsuccessfully.
@Override
protected MockHttpServletResponse loginUnsuccessfully(final String username, final String fromAddress) throws Exception {
final MockHttpServletRequest request = new MockHttpServletRequest();
final MockHttpServletResponse response = new MockHttpServletResponse();
request.setMethod("POST");
request.setParameter("username", username);
request.setRemoteAddr(fromAddress);
final MockRequestContext context = new MockRequestContext();
context.setCurrentEvent(new Event(StringUtils.EMPTY, "error"));
request.setAttribute("flowRequestContext", context);
ClientInfoHolder.setClientInfo(new ClientInfo(request));
response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
throttle.preHandle(request, response, null);
try {
authenticationManager.authenticate(AuthenticationTransaction.wrap(CoreAuthenticationTestUtils.getService(), badCredentials(username)));
} catch (final AuthenticationException e) {
throttle.postHandle(request, response, null, null);
return response;
}
fail("Expected AbstractAuthenticationException");
return null;
}
Aggregations