use of org.springframework.webflow.context.servlet.ServletExternalContext in project cas by apereo.
the class InitialFlowSetupActionCookieTests method verifyResettingContextPath.
@Test
public void verifyResettingContextPath() {
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());
request.setContextPath(CONST_CONTEXT_PATH_2);
this.action.doExecute(context);
assertNotSame(CONST_CONTEXT_PATH_2 + '/', this.warnCookieGenerator.getCookiePath());
assertNotSame(CONST_CONTEXT_PATH_2 + '/', this.tgtCookieGenerator.getCookiePath());
assertEquals(CONST_CONTEXT_PATH + '/', this.warnCookieGenerator.getCookiePath());
assertEquals(CONST_CONTEXT_PATH + '/', this.tgtCookieGenerator.getCookiePath());
}
use of org.springframework.webflow.context.servlet.ServletExternalContext in project cas by apereo.
the class LogoutActionTests method onSetUp.
@Before
public void onSetUp() {
this.request = new MockHttpServletRequest();
this.requestContext = mock(RequestContext.class);
final ServletExternalContext servletExternalContext = mock(ServletExternalContext.class);
when(this.requestContext.getExternalContext()).thenReturn(servletExternalContext);
when(servletExternalContext.getNativeRequest()).thenReturn(request);
when(servletExternalContext.getNativeResponse()).thenReturn(new MockHttpServletResponse());
when(this.requestContext.getFlowScope()).thenReturn(new LocalAttributeMap());
this.serviceManager = new DefaultServicesManager(new InMemoryServiceRegistry(), mock(ApplicationEventPublisher.class));
this.serviceManager.load();
}
use of org.springframework.webflow.context.servlet.ServletExternalContext in project cas by apereo.
the class SendTicketGrantingTicketActionSsoTests method verifySsoSessionCookieOnServiceSsoDisallowed.
@Test
public void verifySsoSessionCookieOnServiceSsoDisallowed() throws Exception {
final MockHttpServletResponse response = new MockHttpServletResponse();
final MockHttpServletRequest request = new MockHttpServletRequest();
final WebApplicationService svc = mock(WebApplicationService.class);
when(svc.getId()).thenReturn("TestSsoFalse");
final TicketGrantingTicket tgt = mock(TicketGrantingTicket.class);
when(tgt.getId()).thenReturn(TEST_STRING);
request.setCookies(new Cookie("TGT", "test5"));
WebUtils.putTicketGrantingTicketInScopes(this.context, tgt);
this.context.setExternalContext(new ServletExternalContext(new MockServletContext(), request, response));
this.context.getFlowScope().put(CasProtocolConstants.PARAMETER_SERVICE, svc);
assertEquals(SUCCESS, action.execute(this.context).getId());
assertEquals(0, response.getCookies().length);
}
use of org.springframework.webflow.context.servlet.ServletExternalContext in project cas by apereo.
the class OpenIdSingleSignOnActionTests method verifyBadUsername.
@Test
public void verifyBadUsername() throws Exception {
final MockRequestContext context = new MockRequestContext();
final MockHttpServletRequest request = new MockHttpServletRequest();
request.setParameter(OpenIdProtocolConstants.OPENID_IDENTITY, "fablah");
request.setParameter(OpenIdProtocolConstants.OPENID_RETURNTO, "http://www.cnn.com");
final OpenIdServiceFactory factory = new OpenIdServiceFactory("");
final OpenIdService service = factory.createService(request);
context.getFlowScope().put("service", service);
context.getFlowScope().put(WebUtils.PARAMETER_TICKET_GRANTING_TICKET_ID, "tgtId");
context.setExternalContext(new ServletExternalContext(new MockServletContext(), request, new MockHttpServletResponse()));
assertEquals("error", this.action.execute(context).getId());
}
use of org.springframework.webflow.context.servlet.ServletExternalContext in project cas by apereo.
the class ClientAuthenticationHandlerTests method setUp.
@Before
public void setUp() {
this.fbClient = new FacebookClient();
final Clients clients = new Clients(CALLBACK_URL, fbClient);
this.handler = new ClientAuthenticationHandler("", mock(ServicesManager.class), null, clients);
this.handler.setTypedIdUsed(true);
final Credentials credentials = new OAuth20Credentials(null);
this.clientCredential = new ClientCredential(credentials, fbClient.getName());
final ServletExternalContext mock = new ServletExternalContext(new MockServletContext(), new MockHttpServletRequest(), new MockHttpServletResponse());
ExternalContextHolder.setExternalContext(mock);
}
Aggregations