use of org.springframework.mock.web.MockHttpServletRequest in project cas by apereo.
the class WebApplicationServiceFactoryTests method verifyServiceCreationSuccessfullyByService.
@Test
public void verifyServiceCreationSuccessfullyByService() {
final MockHttpServletRequest request = new MockHttpServletRequest();
request.addParameter(CasProtocolConstants.PARAMETER_SERVICE, "test");
final WebApplicationServiceFactory factory = new WebApplicationServiceFactory();
final WebApplicationService service = factory.createService(request);
assertNotNull(service);
}
use of org.springframework.mock.web.MockHttpServletRequest in project cas by apereo.
the class CentralAuthenticationServiceImplTests method authenticateTwiceWithRenew.
/**
* This test simulates :
* - a first authentication for a default service
* - a second authentication with the renew parameter and the same service (and same credentials)
* - a validation of the second ticket.
* When supplemental authentications were returned with the chained authentications, the validation specification
* failed as it only expects one authentication. Thus supplemental authentications should not be returned in the
* chained authentications. Both concepts are orthogonal.
*/
@Test
public void authenticateTwiceWithRenew() throws AbstractTicketException, AuthenticationException {
final CentralAuthenticationService cas = getCentralAuthenticationService();
final Service svc = getService("testDefault");
final UsernamePasswordCredential goodCredential = CoreAuthenticationTestUtils.getCredentialsWithSameUsernameAndPassword();
final AuthenticationResult ctx = CoreAuthenticationTestUtils.getAuthenticationResult(getAuthenticationSystemSupport(), svc);
final TicketGrantingTicket tgtId = cas.createTicketGrantingTicket(ctx);
cas.grantServiceTicket(tgtId.getId(), svc, ctx);
// simulate renew with new good same credentials
final ServiceTicket st2Id = cas.grantServiceTicket(tgtId.getId(), svc, ctx);
final Assertion assertion = cas.validateServiceTicket(st2Id.getId(), svc);
final ValidationSpecification validationSpecification = new Cas20WithoutProxyingValidationSpecification();
assertTrue(validationSpecification.isSatisfiedBy(assertion, new MockHttpServletRequest()));
}
use of org.springframework.mock.web.MockHttpServletRequest in project cas by apereo.
the class InitialFlowSetupActionCookieTests method verifySettingContextPath.
@Test
public void verifySettingContextPath() throws Exception {
final MockHttpServletRequest request = new MockHttpServletRequest();
request.setContextPath(CONST_CONTEXT_PATH);
final MockRequestContext 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.mock.web.MockHttpServletRequest in project cas by apereo.
the class InitialFlowSetupActionSsoTests method disableFlowIfNoService.
@Test
public void disableFlowIfNoService() throws Exception {
final MockRequestContext context = new MockRequestContext();
final MockHttpServletRequest request = new MockHttpServletRequest();
context.setExternalContext(new ServletExternalContext(new MockServletContext(), request, new MockHttpServletResponse()));
this.thrown.expect(NoSuchFlowExecutionException.class);
this.thrown.expectMessage(startsWith("No flow execution could be found with key 'null'"));
this.action.execute(context);
}
use of org.springframework.mock.web.MockHttpServletRequest in project cas by apereo.
the class InitialFlowSetupActionTests method verifyNoServiceFound.
@Test
public void verifyNoServiceFound() throws Exception {
final MockRequestContext context = new MockRequestContext();
context.setExternalContext(new ServletExternalContext(new MockServletContext(), new MockHttpServletRequest(), new MockHttpServletResponse()));
final Event event = this.action.execute(context);
assertNull(WebUtils.getService(context));
assertEquals("success", event.getId());
}
Aggregations