use of org.springframework.webflow.test.MockRequestContext in project cas by apereo.
the class RemoveGoogleAnalyticsCookieActionTests method verifyOperation.
@Test
public void verifyOperation() throws Exception {
val context = new MockRequestContext();
val request = new MockHttpServletRequest();
val response = new MockHttpServletResponse();
context.setExternalContext(new ServletExternalContext(new MockServletContext(), request, response));
RequestContextHolder.setRequestContext(context);
ExternalContextHolder.setExternalContext(context.getExternalContext());
assertNull(removeGoogleAnalyticsCookieAction.execute(context));
}
use of org.springframework.webflow.test.MockRequestContext in project cas by apereo.
the class GrouperMultifactorAuthenticationPolicyEventResolverTests method verifyOperation.
@Test
public void verifyOperation() {
val context = new MockRequestContext();
val request = new MockHttpServletRequest();
context.setExternalContext(new ServletExternalContext(new MockServletContext(), request, new MockHttpServletResponse()));
WebUtils.putServiceIntoFlowScope(context, CoreAuthenticationTestUtils.getWebApplicationService());
TestMultifactorAuthenticationProvider.registerProviderIntoApplicationContext(applicationContext);
WebUtils.putAuthentication(CoreAuthenticationTestUtils.getAuthentication(), context);
val targetResolver = new DefaultTargetStateResolver(TestMultifactorAuthenticationProvider.ID);
val transition = new Transition(new DefaultTransitionCriteria(new LiteralExpression(TestMultifactorAuthenticationProvider.ID)), targetResolver);
context.getRootFlow().getGlobalTransitionSet().add(transition);
val event = resolver.resolve(context);
assertEquals(1, event.size());
assertEquals(TestMultifactorAuthenticationProvider.ID, event.iterator().next().getId());
}
use of org.springframework.webflow.test.MockRequestContext in project cas by apereo.
the class DisplayUserGraphicsBeforeAuthenticationActionTests method verifyAction.
@Test
public void verifyAction() throws Exception {
val context = new MockRequestContext();
val request = new MockHttpServletRequest();
request.addParameter("username", "casuser");
context.setExternalContext(new ServletExternalContext(new MockServletContext(), request, new MockHttpServletResponse()));
val event = displayUserGraphicsBeforeAuthenticationAction.execute(context);
assertEquals(CasWebflowConstants.TRANSITION_ID_SUCCESS, event.getId());
assertTrue(WebUtils.containsGraphicalUserAuthenticationImage(context));
assertTrue(WebUtils.containsGraphicalUserAuthenticationUsername(context));
}
use of org.springframework.webflow.test.MockRequestContext in project cas by apereo.
the class PrepareForGraphicalAuthenticationActionTests method verifyAction.
@Test
public void verifyAction() throws Exception {
val context = new MockRequestContext();
val request = new MockHttpServletRequest();
context.setExternalContext(new ServletExternalContext(new MockServletContext(), request, new MockHttpServletResponse()));
val event = initializeLoginAction.execute(context);
assertEquals(GraphicalUserAuthenticationWebflowConfigurer.TRANSITION_ID_GUA_GET_USERID, event.getId());
}
use of org.springframework.webflow.test.MockRequestContext in project cas by apereo.
the class PrepareForGraphicalAuthenticationActionTests method verifyMissingAction.
@Test
public void verifyMissingAction() throws Exception {
val context = new MockRequestContext();
val request = new MockHttpServletRequest();
WebUtils.putGraphicalUserAuthenticationUsername(context, "casuser");
context.setExternalContext(new ServletExternalContext(new MockServletContext(), request, new MockHttpServletResponse()));
val event = initializeLoginAction.execute(context);
assertEquals(CasWebflowConstants.TRANSITION_ID_SUCCESS, event.getId());
}
Aggregations