use of org.springframework.mock.web.MockServletContext in project cas by apereo.
the class LdapSpnegoKnownClientSystemsFilterActionTests method ensureLdapAttributeShouldDoSpnego.
@Test
public void ensureLdapAttributeShouldDoSpnego() throws Exception {
final MockRequestContext ctx = new MockRequestContext();
final MockHttpServletRequest req = new MockHttpServletRequest();
req.setRemoteAddr("localhost");
final ServletExternalContext extCtx = new ServletExternalContext(new MockServletContext(), req, new MockHttpServletResponse());
ctx.setExternalContext(extCtx);
final Event ev = action.execute(ctx);
assertEquals(ev.getId(), new EventFactorySupport().yes(this).getId());
}
use of org.springframework.mock.web.MockServletContext in project spring-security by spring-projects.
the class HttpSessionEventPublisherTests method sessionCreatedNullApplicationContext.
// SEC-2599
@Test(expected = IllegalStateException.class)
public void sessionCreatedNullApplicationContext() {
HttpSessionEventPublisher publisher = new HttpSessionEventPublisher();
MockServletContext servletContext = new MockServletContext();
MockHttpSession session = new MockHttpSession(servletContext);
HttpSessionEvent event = new HttpSessionEvent(session);
publisher.sessionCreated(event);
}
use of org.springframework.mock.web.MockServletContext 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());
}
use of org.springframework.mock.web.MockServletContext in project cas by apereo.
the class AuthenticationViaFormActionTests method verifySuccessfulAuthenticationWithServiceAndWarn.
@Test
public void verifySuccessfulAuthenticationWithServiceAndWarn() throws Exception {
final MockHttpServletRequest request = new MockHttpServletRequest();
final MockHttpServletResponse response = new MockHttpServletResponse();
final MockRequestContext context = new MockRequestContext();
request.addParameter(USERNAME_PARAM, TEST);
request.addParameter(PASSWORD_PARAM, TEST);
request.addParameter("warn", "true");
request.addParameter(CasProtocolConstants.PARAMETER_SERVICE, TEST);
context.setExternalContext(new ServletExternalContext(new MockServletContext(), request, response));
final Credential c = CoreAuthenticationTestUtils.getCredentialsWithSameUsernameAndPassword();
putCredentialInRequestScope(context, c);
assertEquals(CasWebflowConstants.TRANSITION_ID_SUCCESS, this.action.execute(context).getId());
assertNotNull(response.getCookie(this.warnCookieGenerator.getCookieName()));
}
use of org.springframework.mock.web.MockServletContext in project cas by apereo.
the class AuthenticationViaFormActionTests method verifyRenewWithServiceAndSameCredentials.
@Test
public void verifyRenewWithServiceAndSameCredentials() throws Exception {
final Credential c = CoreAuthenticationTestUtils.getCredentialsWithSameUsernameAndPassword();
final Service service = RegisteredServiceTestUtils.getService(RegisteredServiceTestUtils.CONST_TEST_URL);
final AuthenticationResult ctx = CoreAuthenticationTestUtils.getAuthenticationResult(getAuthenticationSystemSupport(), service, c);
final TicketGrantingTicket ticketGrantingTicket = getCentralAuthenticationService().createTicketGrantingTicket(ctx);
final MockHttpServletRequest request = new MockHttpServletRequest();
final MockRequestContext context = new MockRequestContext();
WebUtils.putTicketGrantingTicketInScopes(context, ticketGrantingTicket);
request.addParameter(CasProtocolConstants.PARAMETER_RENEW, "true");
request.addParameter(CasProtocolConstants.PARAMETER_SERVICE, RegisteredServiceTestUtils.getService(RegisteredServiceTestUtils.CONST_TEST_URL).getId());
putCredentialInRequestScope(context, CoreAuthenticationTestUtils.getCredentialsWithSameUsernameAndPassword());
context.setExternalContext(new ServletExternalContext(new MockServletContext(), request, new MockHttpServletResponse()));
context.getFlowScope().put(CasProtocolConstants.PARAMETER_SERVICE, RegisteredServiceTestUtils.getService());
final Event ev = this.action.execute(context);
assertEquals(CasWebflowConstants.STATE_ID_SUCCESS, ev.getId());
}
Aggregations