1
0
mirror of synced 2026-08-05 17:57:15 +00:00

SEC-585: Made expiredUrl optional.

Also implemented Ordered interface for use in namespace configuration.
This commit is contained in:
Luke Taylor
2007-10-26 23:32:40 +00:00
parent 55ef50a4df
commit 3d9ea49d19
2 changed files with 49 additions and 58 deletions
@@ -40,10 +40,6 @@ import java.util.Date;
public class ConcurrentSessionFilterTests extends TestCase {
//~ Constructors ===================================================================================================
public ConcurrentSessionFilterTests() {
super();
}
public ConcurrentSessionFilterTests(String arg0) {
super(arg0);
}
@@ -58,10 +54,6 @@ public class ConcurrentSessionFilterTests extends TestCase {
filter.destroy();
}
public static void main(String[] args) {
junit.textui.TestRunner.run(ConcurrentSessionFilterTests.class);
}
public void testDetectsExpiredSessions() throws Exception {
// Setup our HTTP request
MockHttpServletRequest request = new MockHttpServletRequest();
@@ -88,16 +80,27 @@ public class ConcurrentSessionFilterTests extends TestCase {
assertEquals("/expired.jsp", response.getRedirectedUrl());
}
public void testDetectsMissingExpiredUrl() throws Exception {
ConcurrentSessionFilter filter = new ConcurrentSessionFilter();
filter.setSessionRegistry(new SessionRegistryImpl());
// As above, but with no expiredUrl set.
public void testReturnsExpectedMessageWhenNoExpiredUrlSet() throws Exception {
MockHttpServletRequest request = new MockHttpServletRequest();
MockHttpSession session = new MockHttpSession();
request.setSession(session);
try {
filter.afterPropertiesSet();
fail("Should have thrown IAE");
} catch (IllegalArgumentException expected) {
assertTrue(true);
}
MockHttpServletResponse response = new MockHttpServletResponse();
MockFilterConfig config = new MockFilterConfig(null, null);
MockFilterChain chain = new MockFilterChain(false);
ConcurrentSessionFilter filter = new ConcurrentSessionFilter();
SessionRegistry registry = new SessionRegistryImpl();
registry.registerNewSession(session.getId(), "principal");
registry.getSessionInformation(session.getId()).expireNow();
filter.setSessionRegistry(registry);
executeFilterInContainerSimulator(config, filter, request, response, chain);
assertEquals("This session has been expired (possibly due to multiple concurrent logins being " +
"attempted as the same user).", response.getContentAsString());
}
public void testDetectsMissingSessionRegistry() throws Exception {