use of org.apereo.inspektr.common.web.ClientInfo in project cas by apereo.
the class ConfirmLogoutActionTests method verifyByCookie.
@Test
public void verifyByCookie() throws Exception {
val context = new MockRequestContext();
val response = new MockHttpServletResponse();
val request = new MockHttpServletRequest();
request.setRemoteAddr("185.86.151.11");
request.setLocalAddr("185.88.151.11");
request.addHeader("User-Agent", "agent");
ClientInfoHolder.setClientInfo(new ClientInfo(request));
context.setExternalContext(new ServletExternalContext(new MockServletContext(), request, response));
val ticket = new MockTicketGrantingTicket("casuser");
getCentralAuthenticationService().addTicket(ticket);
val c = getTicketGrantingTicketCookieGenerator().addCookie(request, response, ticket.getId());
request.setCookies(c);
val result = action.execute(context);
assertEquals(CasWebflowConstants.TRANSITION_ID_SUCCESS, result.getId());
assertNotNull(WebUtils.getAuthentication(context));
assertNotNull(WebUtils.getTicketGrantingTicket(context));
}
use of org.apereo.inspektr.common.web.ClientInfo in project cas by apereo.
the class WsFederationCookieManagerTests method verifyOperation.
@Test
public void verifyOperation() {
val context = new MockRequestContext();
val request = new MockHttpServletRequest();
val response = new MockHttpServletResponse();
context.setExternalContext(new ServletExternalContext(new MockServletContext(), request, response));
request.setRemoteAddr("185.86.151.11");
request.setLocalAddr("185.88.151.11");
request.addHeader(HttpRequestUtils.USER_AGENT_HEADER, "MSIE");
ClientInfoHolder.setClientInfo(new ClientInfo(request));
request.addParameter(CasProtocolConstants.PARAMETER_METHOD, "POST");
request.setAttribute("locale", "en");
request.setAttribute("theme", "custom");
val config = wsFederationConfigurations.toList().get(0);
val wctx = config.getId();
val original = RegisteredServiceTestUtils.getService();
wsFederationCookieManager.store(request, response, wctx, original, config);
request.addParameter(WsFederationCookieManager.WCTX, wctx);
request.setCookies(response.getCookies());
val service = wsFederationCookieManager.retrieve(context);
assertNotNull(service);
assertEquals(original.getId(), service.getId());
}
Aggregations