use of org.springframework.webflow.test.MockRequestContext in project cas by apereo.
the class InterruptSingleSignOnParticipationStrategyTests method verifyStrategyWithoutInterrupt.
@Test
public void verifyStrategyWithoutInterrupt() {
val ssoRequest = SingleSignOnParticipationRequest.builder().httpServletRequest(new MockHttpServletRequest()).requestContext(new MockRequestContext()).build();
assertFalse(interruptSingleSignOnParticipationStrategy.isParticipating(ssoRequest));
}
use of org.springframework.webflow.test.MockRequestContext in project cas by apereo.
the class FinalizeInterruptFlowActionTests method verifyFinalizedInterruptNonBlocked.
@Test
public void verifyFinalizedInterruptNonBlocked() throws Exception {
val context = new MockRequestContext();
val request = new MockHttpServletRequest();
val response = new MockHttpServletResponse();
context.setExternalContext(new ServletExternalContext(new MockServletContext(), request, response));
val interrupt = InterruptResponse.interrupt();
InterruptUtils.putInterruptIn(context, interrupt);
WebUtils.putAuthentication(CoreAuthenticationTestUtils.getAuthentication(), context);
WebUtils.putRegisteredService(context, CoreAuthenticationTestUtils.getRegisteredService());
val action = new FinalizeInterruptFlowAction(mock(CasCookieBuilder.class));
val event = action.doExecute(context);
assertEquals(event.getId(), CasWebflowConstants.TRANSITION_ID_SUCCESS);
val authn = WebUtils.getAuthentication(context);
assertTrue(authn.getAttributes().containsKey(InquireInterruptAction.AUTHENTICATION_ATTRIBUTE_FINALIZED_INTERRUPT));
}
use of org.springframework.webflow.test.MockRequestContext in project cas by apereo.
the class FinalizeInterruptFlowActionTests method verifyFinalizedInterruptBlocked.
@Test
public void verifyFinalizedInterruptBlocked() {
val context = new MockRequestContext();
val request = new MockHttpServletRequest();
val response = new MockHttpServletResponse();
context.setExternalContext(new ServletExternalContext(new MockServletContext(), request, response));
val interrupt = InterruptResponse.interrupt();
interrupt.setBlock(true);
InterruptUtils.putInterruptIn(context, interrupt);
WebUtils.putRegisteredService(context, CoreAuthenticationTestUtils.getRegisteredService());
val action = new FinalizeInterruptFlowAction(mock(CasCookieBuilder.class));
assertThrows(UnauthorizedServiceException.class, () -> action.doExecute(context));
}
use of org.springframework.webflow.test.MockRequestContext in project cas by apereo.
the class RegexAttributeInterruptInquirerTests method verifyInterruptSkippedWithServicePolicy.
@Test
public void verifyInterruptSkippedWithServicePolicy() {
val q = new RegexAttributeInterruptInquirer("member..", "CA.|system");
val registeredService = RegisteredServiceTestUtils.getRegisteredService();
registeredService.setWebflowInterruptPolicy(new DefaultRegisteredServiceWebflowInterruptPolicy().setEnabled(false));
val response = q.inquire(CoreAuthenticationTestUtils.getAuthentication("casuser"), registeredService, CoreAuthenticationTestUtils.getService(), CoreAuthenticationTestUtils.getCredentialsWithSameUsernameAndPassword(), new MockRequestContext());
assertNotNull(response);
assertFalse(response.isInterrupt());
}
use of org.springframework.webflow.test.MockRequestContext in project cas by apereo.
the class RestEndpointInterruptInquirerTests method verifyResponseCanBeFoundFromRest.
@Test
public void verifyResponseCanBeFoundFromRest() {
val restProps = new RestfulInterruptProperties();
restProps.setUrl("http://localhost:8888");
val context = new MockRequestContext();
val request = new MockHttpServletRequest();
request.addHeader("accept-language", "fr");
context.setExternalContext(new ServletExternalContext(new MockServletContext(), request, new MockHttpServletResponse()));
val q = new RestEndpointInterruptInquirer(restProps);
val response = q.inquire(CoreAuthenticationTestUtils.getAuthentication("casuser"), CoreAuthenticationTestUtils.getRegisteredService(), CoreAuthenticationTestUtils.getService(), CoreAuthenticationTestUtils.getCredentialsWithSameUsernameAndPassword(), context);
assertNotNull(response);
assertTrue(response.isBlock());
assertTrue(response.isSsoEnabled());
assertEquals(2, response.getLinks().size());
assertEquals(getClass().getSimpleName(), response.getMessage());
}
Aggregations