HttpSessionSecurityContextRepository.SPRING_SECURITY_CONTEXT_KEY);
assertNotNull(ctx);
Authentication auth = ctx.getAuthentication();
assertNotNull(auth);
assertNull(SecurityContextHolder.getContext().getAuthentication());
MockHttpSession session = (MockHttpSession) request.getSession(false);
assertNotNull(session);
assertTrue(session.isValid());
// logout triggered by geoserver
request = createRequest(logoutchain.getPatterns().get(0));
//request.getSession().setAttribute(HttpSessionSecurityContextRepository.SPRING_SECURITY_CONTEXT_KEY, ctx);
SecurityContextHolder.setContext(ctx);
response = new MockHttpServletResponse();
chain = new MockFilterChain();
//getProxy().doFilter(request, response, chain);
GeoServerLogoutFilter logoutFilter=
(GeoServerLogoutFilter) getSecurityManager().loadFilter(GeoServerSecurityFilterChain.FORM_LOGOUT_FILTER);
logoutFilter.doFilter(request, response, chain);
assertEquals(HttpServletResponse.SC_OK, response.getErrorCode());
assertTrue(response.wasRedirectSent());
String redirectUrl = response.getHeader("Location");
assertNotNull(redirectUrl);
assertTrue(redirectUrl.contains(GeoServerCasConstants.LOGOUT_URI));
session = (MockHttpSession) request.getSession(false);
// login
helper = new CasFormAuthenticationHelper(casServerURLPrefix,
username, password);
helper.ssoLogin();
request = createRequest(pattern);
response = new MockHttpServletResponse();
chain = new MockFilterChain();
String ticket = loginUsingTicket(helper, request, response, chain);
assertEquals(HttpServletResponse.SC_OK, response.getErrorCode());
assertFalse(response.wasRedirectSent());
ctx = (SecurityContext) request.getSession(false).getAttribute(
HttpSessionSecurityContextRepository.SPRING_SECURITY_CONTEXT_KEY);
assertNotNull(ctx);
auth = ctx.getAuthentication();
assertNotNull(auth);
assertNull(SecurityContextHolder.getContext().getAuthentication());
session = (MockHttpSession) request.getSession(false);
assertNotNull(session);
assertTrue(session.isValid());
// logout triggered by cas server
request = createRequest(pattern);
//request.getSession().setAttribute(HttpSessionSecurityContextRepository.SPRING_SECURITY_CONTEXT_KEY, ctx);