use of org.springframework.webflow.test.MockRequestContext in project cas by apereo.
the class RenderLoginActionTests method verifyGroovyRender.
@Test
public void verifyGroovyRender() 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());
val properties = new CasConfigurationProperties();
properties.getWebflow().getLoginDecorator().getGroovy().setLocation(new ClassPathResource("GroovyLoginDecorator.groovy"));
val action = new RenderLoginAction(getServicesManager(), properties, applicationContext);
assertNull(action.execute(context));
}
use of org.springframework.webflow.test.MockRequestContext in project cas by apereo.
the class ServiceAuthorizationCheckActionTests method verifyNoServiceFound.
@Test
public void verifyNoServiceFound() {
val request = new MockHttpServletRequest();
val context = new MockRequestContext();
context.setExternalContext(new ServletExternalContext(new MockServletContext(), request, new MockHttpServletResponse()));
WebUtils.putServiceIntoFlowScope(context, RegisteredServiceTestUtils.getService("invalid-service-123"));
assertThrows(UnauthorizedServiceException.class, () -> this.action.execute(context));
}
use of org.springframework.webflow.test.MockRequestContext in project cas by apereo.
the class JdbcAcceptableUsagePolicyRepositoryAdvancedTests method raiseException.
private void raiseException(final Map<String, List<Object>> profileAttributes) {
val aupProperties = casProperties.getAcceptableUsagePolicy();
val jdbcAupRepository = new JdbcAcceptableUsagePolicyRepository(ticketRegistrySupport, aupProperties, acceptableUsagePolicyDataSource, jdbcAcceptableUsagePolicyTransactionTemplate);
val context = new MockRequestContext();
val request = new MockHttpServletRequest();
context.setExternalContext(new ServletExternalContext(new MockServletContext(), request, new MockHttpServletResponse()));
val c = CoreAuthenticationTestUtils.getCredentialsWithSameUsernameAndPassword("casuser");
val principal = CoreAuthenticationTestUtils.getPrincipal(c.getId(), profileAttributes);
val auth = CoreAuthenticationTestUtils.getAuthentication(principal);
WebUtils.putAuthentication(auth, context);
assertNotNull(jdbcAupRepository.determinePrincipalId(principal));
}
use of org.springframework.webflow.test.MockRequestContext in project cas by apereo.
the class InitialFlowSetupCookieActionTests method verifySettingContextPath.
@Test
public void verifySettingContextPath() {
val request = new MockHttpServletRequest();
request.setContextPath(CONST_CONTEXT_PATH);
val context = new MockRequestContext();
context.setExternalContext(new ServletExternalContext(new MockServletContext(), request, new MockHttpServletResponse()));
this.action.doExecute(context);
assertEquals(CONST_CONTEXT_PATH + '/', this.warnCookieGenerator.getCookiePath());
assertEquals(CONST_CONTEXT_PATH + '/', this.tgtCookieGenerator.getCookiePath());
}
use of org.springframework.webflow.test.MockRequestContext in project cas by apereo.
the class InterruptSingleSignOnParticipationStrategyTests method verifyStrategyWithInterruptDisabled.
@Test
public void verifyStrategyWithInterruptDisabled() {
val ctx = new MockRequestContext();
val response = new InterruptResponse();
response.setSsoEnabled(false);
InterruptUtils.putInterruptIn(ctx, response);
val ssoRequest = SingleSignOnParticipationRequest.builder().httpServletRequest(new MockHttpServletRequest()).requestContext(ctx).build();
assertTrue(interruptSingleSignOnParticipationStrategy.supports(ssoRequest));
assertFalse(interruptSingleSignOnParticipationStrategy.isParticipating(ssoRequest));
}
Aggregations