@Test public void testDropCredentialsSession() { ComponentContext context = configureForSession(); HttpServletRequest request = createMock(HttpServletRequest.class); HttpSession session = createMock(HttpSession.class); EasyMock.expect(request.getSession(false)).andReturn(session); session.setAttribute(TrustedTokenService.SA_AUTHENTICATION_CREDENTIALS, null); EasyMock.expectLastCall(); HttpServletResponse response = createMock(HttpServletResponse.class); replay(); trustedTokenService.activate(context); trustedTokenService.dropCredentials(request, response); verify(); }
@Test public void testDropCredentials() { ComponentContext context = configureForCookie(); HttpServletRequest request = createMock(HttpServletRequest.class); HttpServletResponse response = createMock(HttpServletResponse.class); Capture<Cookie> cookieCapture = new Capture<Cookie>(); response.addCookie(EasyMock.capture(cookieCapture)); EasyMock.expectLastCall(); replay(); trustedTokenService.activate(context); trustedTokenService.dropCredentials(request, response); Assert.assertTrue(cookieCapture.hasCaptured()); Cookie cookie = cookieCapture.getValue(); Assert.assertNotNull(cookie); Assert.assertEquals("secure-cookie", cookie.getName()); String user = trustedTokenService.decodeCookie(cookie.getValue()); Assert.assertNull(user); verify(); }