use of org.springframework.webflow.test.MockRequestContext in project cas by apereo.
the class OpenIdSingleSignOnActionTests method verifyNoTgt.
@Test
public void verifyNoTgt() 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 AbstractInMemoryThrottledSubmissionHandlerInterceptorAdapterTests 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);
response.setStatus(HttpStatus.UNAUTHORIZED.value());
throttle.preHandle(request, response, null);
throttle.postHandle(request, response, null, null);
return response;
}
use of org.springframework.webflow.test.MockRequestContext in project cas by apereo.
the class AllSpnegoKnownClientSystemsFilterActionTests method ensureAltRemoteIpHeaderShouldBeChecked.
@Test
public void ensureAltRemoteIpHeaderShouldBeChecked() {
final BaseSpnegoKnownClientSystemsFilterAction action = new BaseSpnegoKnownClientSystemsFilterAction("^74\\.125\\..+", "alternateRemoteIp", 120);
final MockRequestContext ctx = new MockRequestContext();
final MockHttpServletRequest req = new MockHttpServletRequest();
req.setRemoteAddr("555.555.555.555");
req.addHeader("alternateRemoteIp", ALTERNATE_REMOTE_IP);
final ServletExternalContext extCtx = new ServletExternalContext(new MockServletContext(), req, new MockHttpServletResponse());
ctx.setExternalContext(extCtx);
final Event ev = action.doExecute(ctx);
assertEquals(ev.getId(), new EventFactorySupport().yes(this).getId());
}
use of org.springframework.webflow.test.MockRequestContext in project cas by apereo.
the class AllSpnegoKnownClientSystemsFilterActionTests method ensureHostnameAndIpShouldDoSpnego.
@Test
public void ensureHostnameAndIpShouldDoSpnego() {
final HostNameSpnegoKnownClientSystemsFilterAction action = new HostNameSpnegoKnownClientSystemsFilterAction("74\\..+", "", 0, "\\w+\\.\\w+\\.\\w+");
final MockRequestContext ctx = new MockRequestContext();
final MockHttpServletRequest req = new MockHttpServletRequest();
req.setRemoteAddr(ALTERNATE_REMOTE_IP);
final ServletExternalContext extCtx = new ServletExternalContext(new MockServletContext(), req, new MockHttpServletResponse());
ctx.setExternalContext(extCtx);
final Event ev = action.doExecute(ctx);
assertEquals(ev.getId(), new EventFactorySupport().yes(this).getId());
}
use of org.springframework.webflow.test.MockRequestContext in project cas by apereo.
the class AllSpnegoKnownClientSystemsFilterActionTests method ensureHostnameShouldDoSpnego.
@Test
public void ensureHostnameShouldDoSpnego() {
final HostNameSpnegoKnownClientSystemsFilterAction action = new HostNameSpnegoKnownClientSystemsFilterAction("", "", 0, "\\w+\\.\\w+\\.\\w+");
final MockRequestContext ctx = new MockRequestContext();
final MockHttpServletRequest req = new MockHttpServletRequest();
req.setRemoteAddr(ALTERNATE_REMOTE_IP);
final ServletExternalContext extCtx = new ServletExternalContext(new MockServletContext(), req, new MockHttpServletResponse());
ctx.setExternalContext(extCtx);
final Event ev = action.doExecute(ctx);
assertEquals(ev.getId(), new EventFactorySupport().yes(this).getId());
}
Aggregations