From 4b27499bbc6b6011479305e11885d4135c681da6 Mon Sep 17 00:00:00 2001 From: Jan Bartel Date: Thu, 20 Jul 2017 16:11:19 +0200 Subject: [PATCH] Issue #1681 (cherry picked from commit 0d99bde0c1e740493b6dfab772b3c4933c1e7d75) --- .../ReloadedSessionMissingClassTest.java | 3 --- .../sessions/CachingSessionDataStoreTest.java | 3 --- ...tractClusteredInvalidationSessionTest.java | 2 -- ...bstractClusteredSessionScavengingTest.java | 4 --- ...AbstractModifyMaxInactiveIntervalTest.java | 27 ------------------- ...ractNonClusteredSessionScavengingTest.java | 6 ----- .../AbstractProxySerializationTest.java | 3 --- .../session/AbstractSessionExpiryTest.java | 15 +---------- ...ctSessionInvalidateCreateScavengeTest.java | 3 --- .../jetty/server/session/CreationTest.java | 3 --- .../server/session/DirtyAttributeTest.java | 7 +---- .../jetty/server/session/IdleSessionTest.java | 7 ----- .../server/session/ImmortalSessionTest.java | 3 --- .../session/ReentrantRequestSessionTest.java | 2 -- .../server/session/RemoveSessionTest.java | 5 +--- .../SameContextForwardedSessionTest.java | 3 --- .../server/session/SameNodeLoadTest.java | 4 --- .../server/session/SaveOptimizeTest.java | 17 ------------ .../session/SessionEvictionFailureTest.java | 6 +---- .../server/session/SessionListenerTest.java | 4 --- .../server/session/SessionRenewTest.java | 1 - 21 files changed, 4 insertions(+), 124 deletions(-) diff --git a/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/ReloadedSessionMissingClassTest.java b/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/ReloadedSessionMissingClassTest.java index af2bedf084b..a820209cda0 100644 --- a/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/ReloadedSessionMissingClassTest.java +++ b/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/ReloadedSessionMissingClassTest.java @@ -114,8 +114,6 @@ public class ReloadedSessionMissingClassTest assertTrue(sessionCookie != null); String sessionId = (String)webApp.getServletContext().getAttribute("foo"); assertNotNull(sessionId); - // Mangle the cookie, replacing Path with $Path, etc. - sessionCookie = sessionCookie.replaceFirst("(\\W)(P|p)ath=", "$1\\$Path="); //Stop the webapp webApp.stop(); @@ -126,7 +124,6 @@ public class ReloadedSessionMissingClassTest webApp.start(); Request request = client.newRequest("http://localhost:" + port1 + contextPath + "/bar?action=get"); - request.header("Cookie", sessionCookie); response = request.send(); assertEquals(HttpServletResponse.SC_OK,response.getStatus()); diff --git a/tests/test-sessions/test-memcached-sessions/src/test/java/org/eclipse/jetty/memcached/sessions/CachingSessionDataStoreTest.java b/tests/test-sessions/test-memcached-sessions/src/test/java/org/eclipse/jetty/memcached/sessions/CachingSessionDataStoreTest.java index 4223b905220..488710af8a7 100644 --- a/tests/test-sessions/test-memcached-sessions/src/test/java/org/eclipse/jetty/memcached/sessions/CachingSessionDataStoreTest.java +++ b/tests/test-sessions/test-memcached-sessions/src/test/java/org/eclipse/jetty/memcached/sessions/CachingSessionDataStoreTest.java @@ -83,8 +83,6 @@ public class CachingSessionDataStoreTest assertEquals(HttpServletResponse.SC_OK,response.getStatus()); String sessionCookie = response.getHeaders().get("Set-Cookie"); assertTrue(sessionCookie != null); - // Mangle the cookie, replacing Path with $Path, etc. - sessionCookie = sessionCookie.replaceFirst("(\\W)(P|p)ath=", "$1\\$Path="); String id = TestServer.extractSessionId(sessionCookie); //check that the memcache contains the session, and the session data store contains the session @@ -102,7 +100,6 @@ public class CachingSessionDataStoreTest // ((MockDataStore)persistentStore).zeroLoadCount(); Request request = client.newRequest("http://localhost:" + port + contextPath + servletMapping + "?action=update"); - request.header("Cookie", sessionCookie); response = request.send(); assertEquals(HttpServletResponse.SC_OK,response.getStatus()); assertEquals(0, ((MockDataStore)persistentStore).getLoadCount()); diff --git a/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractClusteredInvalidationSessionTest.java b/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractClusteredInvalidationSessionTest.java index ccd39817ee0..697c2b431aa 100644 --- a/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractClusteredInvalidationSessionTest.java +++ b/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractClusteredInvalidationSessionTest.java @@ -104,13 +104,11 @@ public abstract class AbstractClusteredInvalidationSessionTest extends AbstractT // Invalidate on node1 Request request1 = client.newRequest(urls[0] + "?action=invalidate"); - request1.header("Cookie", sessionCookie); response1 = request1.send(); assertEquals(HttpServletResponse.SC_OK, response1.getStatus()); // Be sure on node2 we don't see the session anymore request2 = client.newRequest(urls[1] + "?action=test"); - request2.header("Cookie", sessionCookie); response2 = request2.send(); assertEquals(HttpServletResponse.SC_OK,response2.getStatus()); } diff --git a/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractClusteredSessionScavengingTest.java b/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractClusteredSessionScavengingTest.java index 1e624e5d5f3..d9b8709e8bd 100644 --- a/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractClusteredSessionScavengingTest.java +++ b/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractClusteredSessionScavengingTest.java @@ -117,8 +117,6 @@ public abstract class AbstractClusteredSessionScavengingTest extends AbstractTes assertEquals(HttpServletResponse.SC_OK,response1.getStatus()); String sessionCookie = response1.getHeaders().get("Set-Cookie"); assertTrue(sessionCookie != null); - // Mangle the cookie, replacing Path with $Path, etc. - sessionCookie = sessionCookie.replaceFirst("(\\W)(P|p)ath=", "$1\\$Path="); SessionHandler m1 = context1.getSessionHandler(); assertEquals(1, m1.getSessionsCreated()); @@ -212,7 +210,6 @@ public abstract class AbstractClusteredSessionScavengingTest extends AbstractTes // Check that node1 does not have any local session cached request = client.newRequest(urls[0] + "?action=check"); - request.header("Cookie", sessionCookie); response1 = request.send(); assertEquals(HttpServletResponse.SC_OK,response1.getStatus()); @@ -224,7 +221,6 @@ public abstract class AbstractClusteredSessionScavengingTest extends AbstractTes // Check that node2 does not have any local session cached request = client.newRequest(urls[1] + "?action=check"); - request.header("Cookie", sessionCookie); response2 = request.send(); assertEquals(HttpServletResponse.SC_OK,response2.getStatus()); } diff --git a/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractModifyMaxInactiveIntervalTest.java b/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractModifyMaxInactiveIntervalTest.java index f09a507901f..f05d1d9c7a5 100644 --- a/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractModifyMaxInactiveIntervalTest.java +++ b/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractModifyMaxInactiveIntervalTest.java @@ -81,18 +81,14 @@ public abstract class AbstractModifyMaxInactiveIntervalTest extends AbstractTest assertEquals(HttpServletResponse.SC_OK,response.getStatus()); String sessionCookie = response.getHeaders().get("Set-Cookie"); assertTrue(sessionCookie != null); - // Mangle the cookie, replacing Path with $Path, etc. - sessionCookie = sessionCookie.replaceFirst("(\\W)(P|p)ath=", "$1\\$Path="); //do another request to reduce the maxinactive interval Request request = client.newRequest("http://localhost:" + port + "/mod/test?action=change&val="+newMaxInactive+"&wait="+sleep); - request.header("Cookie", sessionCookie); response = request.send(); assertEquals(HttpServletResponse.SC_OK,response.getStatus()); //do another request using the cookie to ensure the session is still there request= client.newRequest("http://localhost:" + port + "/mod/test?action=test&val="+newMaxInactive); - request.header("Cookie", sessionCookie); response = request.send(); assertEquals(HttpServletResponse.SC_OK,response.getStatus()); @@ -140,18 +136,14 @@ public abstract class AbstractModifyMaxInactiveIntervalTest extends AbstractTest assertEquals(HttpServletResponse.SC_OK,response.getStatus()); String sessionCookie = response.getHeaders().get("Set-Cookie"); assertTrue(sessionCookie != null); - // Mangle the cookie, replacing Path with $Path, etc. - sessionCookie = sessionCookie.replaceFirst("(\\W)(P|p)ath=", "$1\\$Path="); //do another request to increase the maxinactive interval, first waiting until the old expiration should have passed Request request = client.newRequest("http://localhost:" + port + "/mod/test?action=change&val="+newMaxInactive+"&wait="+sleep); - request.header("Cookie", sessionCookie); response = request.send(); assertEquals(HttpServletResponse.SC_OK,response.getStatus()); //do another request using the cookie to ensure the session is still there request= client.newRequest("http://localhost:" + port + "/mod/test?action=test&val="+newMaxInactive); - request.header("Cookie", sessionCookie); response = request.send(); assertEquals(HttpServletResponse.SC_OK,response.getStatus()); @@ -199,18 +191,14 @@ public abstract class AbstractModifyMaxInactiveIntervalTest extends AbstractTest assertEquals(HttpServletResponse.SC_OK,response.getStatus()); String sessionCookie = response.getHeaders().get("Set-Cookie"); assertTrue(sessionCookie != null); - // Mangle the cookie, replacing Path with $Path, etc. - sessionCookie = sessionCookie.replaceFirst("(\\W)(P|p)ath=", "$1\\$Path="); //do another request to reduce the maxinactive interval Request request = client.newRequest("http://localhost:" + port + "/mod/test?action=change&val="+newMaxInactive+"&wait="+sleep); - request.header("Cookie", sessionCookie); response = request.send(); assertEquals(HttpServletResponse.SC_OK,response.getStatus()); //do another request using the cookie to ensure the session is still there request= client.newRequest("http://localhost:" + port + "/mod/test?action=test&val="+newMaxInactive); - request.header("Cookie", sessionCookie); response = request.send(); assertEquals(HttpServletResponse.SC_OK,response.getStatus()); @@ -258,18 +246,14 @@ public abstract class AbstractModifyMaxInactiveIntervalTest extends AbstractTest assertEquals(HttpServletResponse.SC_OK,response.getStatus()); String sessionCookie = response.getHeaders().get("Set-Cookie"); assertTrue(sessionCookie != null); - // Mangle the cookie, replacing Path with $Path, etc. - sessionCookie = sessionCookie.replaceFirst("(\\W)(P|p)ath=", "$1\\$Path="); //do another request to reduce the maxinactive interval Request request = client.newRequest("http://localhost:" + port + "/mod/test?action=change&val="+newMaxInactive+"&wait="+sleep); - request.header("Cookie", sessionCookie); response = request.send(); assertEquals(HttpServletResponse.SC_OK,response.getStatus()); //do another request using the cookie to ensure the session is still there request= client.newRequest("http://localhost:" + port + "/mod/test?action=test&val="+newMaxInactive); - request.header("Cookie", sessionCookie); response = request.send(); assertEquals(HttpServletResponse.SC_OK,response.getStatus()); @@ -314,18 +298,14 @@ public abstract class AbstractModifyMaxInactiveIntervalTest extends AbstractTest assertEquals(HttpServletResponse.SC_OK,response.getStatus()); String sessionCookie = response.getHeaders().get("Set-Cookie"); assertTrue(sessionCookie != null); - // Mangle the cookie, replacing Path with $Path, etc. - sessionCookie = sessionCookie.replaceFirst("(\\W)(P|p)ath=", "$1\\$Path="); //do another request to change the maxinactive interval Request request = client.newRequest("http://localhost:" + port + "/mod/test?action=change&val="+newMaxInactive+"&wait="+2); - request.header("Cookie", sessionCookie); response = request.send(); assertEquals(HttpServletResponse.SC_OK,response.getStatus()); //do another request using the cookie to ensure the session is still there request= client.newRequest("http://localhost:" + port + "/mod/test?action=test&val="+newMaxInactive); - request.header("Cookie", sessionCookie); response = request.send(); assertEquals(HttpServletResponse.SC_OK,response.getStatus()); @@ -372,13 +352,10 @@ public abstract class AbstractModifyMaxInactiveIntervalTest extends AbstractTest assertEquals(HttpServletResponse.SC_OK,response.getStatus()); String sessionCookie = response.getHeaders().get("Set-Cookie"); assertTrue(sessionCookie != null); - // Mangle the cookie, replacing Path with $Path, etc. - sessionCookie = sessionCookie.replaceFirst("(\\W)(P|p)ath=", "$1\\$Path="); //do another request that will sleep long enough for the session expiry time to have passed //before trying to access the session and ensure it is still there Request request = client.newRequest("http://localhost:" + port + "/mod/test?action=sleep&val="+sleep); - request.header("Cookie", sessionCookie); response = request.send(); assertEquals(HttpServletResponse.SC_OK,response.getStatus()); @@ -426,12 +403,9 @@ public abstract class AbstractModifyMaxInactiveIntervalTest extends AbstractTest assertEquals(HttpServletResponse.SC_OK,response.getStatus()); String sessionCookie = response.getHeaders().get("Set-Cookie"); assertTrue(sessionCookie != null); - // Mangle the cookie, replacing Path with $Path, etc. - sessionCookie = sessionCookie.replaceFirst("(\\W)(P|p)ath=", "$1\\$Path="); //do another request to change the maxinactive interval Request request = client.newRequest("http://localhost:" + port + "/mod/test?action=change&val="+newMaxInactive); - request.header("Cookie", sessionCookie); response = request.send(); assertEquals(HttpServletResponse.SC_OK,response.getStatus()); @@ -441,7 +415,6 @@ public abstract class AbstractModifyMaxInactiveIntervalTest extends AbstractTest //do another request using the cookie to ensure the session is still there request= client.newRequest("http://localhost:" + port + "/mod/test?action=test&val="+newMaxInactive); - request.header("Cookie", sessionCookie); response = request.send(); assertEquals(HttpServletResponse.SC_OK,response.getStatus()); diff --git a/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractNonClusteredSessionScavengingTest.java b/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractNonClusteredSessionScavengingTest.java index c4695b8aec9..c96237b6faa 100644 --- a/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractNonClusteredSessionScavengingTest.java +++ b/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractNonClusteredSessionScavengingTest.java @@ -96,8 +96,6 @@ public abstract class AbstractNonClusteredSessionScavengingTest extends Abstract assertEquals(HttpServletResponse.SC_OK,response.getStatus()); String sessionCookie = response.getHeaders().get("Set-Cookie"); assertTrue(sessionCookie != null); - // Mangle the cookie, replacing Path with $Path, etc. - sessionCookie = sessionCookie.replaceFirst("(\\W)(P|p)ath=", "$1\\$Path="); // Let's wait for the scavenger to run pause(maxInactivePeriod + scavengePeriod); @@ -107,7 +105,6 @@ public abstract class AbstractNonClusteredSessionScavengingTest extends Abstract // The session should not be there anymore, but we present an old cookie // The server should create a new session. Request request = client.newRequest("http://localhost:" + port + contextPath + servletMapping.substring(1) + "?action=old-create"); - request.header("Cookie", sessionCookie); response = request.send(); assertEquals(HttpServletResponse.SC_OK,response.getStatus()); } @@ -154,8 +151,6 @@ public abstract class AbstractNonClusteredSessionScavengingTest extends Abstract assertEquals(HttpServletResponse.SC_OK,response.getStatus()); String sessionCookie = response.getHeaders().get("Set-Cookie"); assertTrue(sessionCookie != null); - // Mangle the cookie, replacing Path with $Path, etc. - sessionCookie = sessionCookie.replaceFirst("(\\W)(P|p)ath=", "$1\\$Path="); // Let's wait for the scavenger to run pause(2*scavengePeriod); @@ -164,7 +159,6 @@ public abstract class AbstractNonClusteredSessionScavengingTest extends Abstract // Test that the session is still there Request request = client.newRequest("http://localhost:" + port + contextPath + servletMapping.substring(1) + "?action=old-test"); - request.header("Cookie", sessionCookie); response = request.send(); assertEquals(HttpServletResponse.SC_OK,response.getStatus()); } diff --git a/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractProxySerializationTest.java b/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractProxySerializationTest.java index 431b17b3805..f40132a25c6 100644 --- a/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractProxySerializationTest.java +++ b/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractProxySerializationTest.java @@ -108,8 +108,6 @@ public abstract class AbstractProxySerializationTest extends AbstractTestBase assertEquals(HttpServletResponse.SC_OK,response.getStatus()); String sessionCookie = response.getHeaders().get("Set-Cookie"); assertTrue(sessionCookie != null); - // Mangle the cookie, replacing Path with $Path, etc. - sessionCookie = sessionCookie.replaceFirst("(\\W)(P|p)ath=", "$1\\$Path="); //stop the context to be sure the sesssion will be passivated context.stop(); @@ -119,7 +117,6 @@ public abstract class AbstractProxySerializationTest extends AbstractTestBase // Make another request using the session id from before Request request = client.newRequest("http://localhost:" + port + contextPath + servletMapping.substring(1) + "?action=test"); - request.header("Cookie", sessionCookie); response = request.send(); assertEquals(HttpServletResponse.SC_OK,response.getStatus()); } diff --git a/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractSessionExpiryTest.java b/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractSessionExpiryTest.java index fa2c153b73f..523867b63fb 100644 --- a/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractSessionExpiryTest.java +++ b/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractSessionExpiryTest.java @@ -141,8 +141,6 @@ public abstract class AbstractSessionExpiryTest extends AbstractTestBase assertEquals(HttpServletResponse.SC_OK,response1.getStatus()); String sessionCookie = response1.getHeaders().get("Set-Cookie"); assertTrue(sessionCookie != null); - // Mangle the cookie, replacing Path with $Path, etc. - sessionCookie = sessionCookie.replaceFirst("(\\W)(P|p)ath=", "$1\\$Path="); String sessionId = TestServer.extractSessionId(sessionCookie); @@ -197,8 +195,6 @@ public abstract class AbstractSessionExpiryTest extends AbstractTestBase assertEquals(HttpServletResponse.SC_OK,response.getStatus()); String sessionCookie = response.getHeaders().get("Set-Cookie"); assertTrue(sessionCookie != null); - // Mangle the cookie, replacing Path with $Path, etc. - sessionCookie = sessionCookie.replaceFirst("(\\W)(P|p)ath=", "$1\\$Path="); //now stop the server server1.stop(); @@ -211,7 +207,6 @@ public abstract class AbstractSessionExpiryTest extends AbstractTestBase //make another request, the session should not have expired Request request = client.newRequest(url + "?action=notexpired"); - request.getHeaders().add("Cookie", sessionCookie); ContentResponse response2 = request.send(); assertEquals(HttpServletResponse.SC_OK,response2.getStatus()); @@ -268,8 +263,6 @@ public abstract class AbstractSessionExpiryTest extends AbstractTestBase assertEquals(HttpServletResponse.SC_OK,response1.getStatus()); String sessionCookie = response1.getHeaders().get("Set-Cookie"); assertTrue(sessionCookie != null); - // Mangle the cookie, replacing Path with $Path, etc. - sessionCookie = sessionCookie.replaceFirst("(\\W)(P|p)ath=", "$1\\$Path="); String sessionId = TestServer.extractSessionId(sessionCookie); @@ -292,7 +285,6 @@ public abstract class AbstractSessionExpiryTest extends AbstractTestBase //make another request, the session should have expired Request request = client.newRequest(url + "?action=test"); - request.getHeaders().add("Cookie", sessionCookie); ContentResponse response2 = request.send(); assertEquals(HttpServletResponse.SC_OK,response2.getStatus()); @@ -343,15 +335,11 @@ public abstract class AbstractSessionExpiryTest extends AbstractTestBase ContentResponse response = client.GET(url + "?action=init"); assertEquals(HttpServletResponse.SC_OK,response.getStatus()); String sessionCookie = response.getHeaders().get("Set-Cookie"); - assertTrue(sessionCookie != null); - // Mangle the cookie, replacing Path with $Path, etc. - sessionCookie = sessionCookie.replaceFirst("(\\W)(P|p)ath=", "$1\\$Path="); - + assertTrue(sessionCookie != null); //make another request to change the session timeout to a larger value int newInactivePeriod = 100; Request request = client.newRequest(url + "?action=change&val="+newInactivePeriod); - request.getHeaders().add("Cookie", sessionCookie); response = request.send(); assertEquals(HttpServletResponse.SC_OK,response.getStatus()); @@ -364,7 +352,6 @@ public abstract class AbstractSessionExpiryTest extends AbstractTestBase pause(inactivePeriod); request = client.newRequest(url + "?action=check"); - request.getHeaders().add("Cookie", sessionCookie); response = request.send(); assertEquals(HttpServletResponse.SC_OK,response.getStatus()); String sessionCookie2 = response.getHeaders().get("Set-Cookie"); diff --git a/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractSessionInvalidateCreateScavengeTest.java b/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractSessionInvalidateCreateScavengeTest.java index 88edd817e55..e348ab0a1b6 100644 --- a/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractSessionInvalidateCreateScavengeTest.java +++ b/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractSessionInvalidateCreateScavengeTest.java @@ -123,12 +123,9 @@ public abstract class AbstractSessionInvalidateCreateScavengeTest extends Abstra assertEquals(HttpServletResponse.SC_OK,response1.getStatus()); String sessionCookie = response1.getHeaders().get("Set-Cookie"); assertTrue(sessionCookie != null); - // Mangle the cookie, replacing Path with $Path, etc. - sessionCookie = sessionCookie.replaceFirst("(\\W)(P|p)ath=", "$1\\$Path="); // Make a request which will invalidate the existing session and create a new one Request request2 = client.newRequest(url + "?action=test"); - request2.header("Cookie", sessionCookie); ContentResponse response2 = request2.send(); assertEquals(HttpServletResponse.SC_OK,response2.getStatus()); diff --git a/tests/test-sessions/test-sessions-common/src/test/java/org/eclipse/jetty/server/session/CreationTest.java b/tests/test-sessions/test-sessions-common/src/test/java/org/eclipse/jetty/server/session/CreationTest.java index 2273b14ab09..c10733a1042 100644 --- a/tests/test-sessions/test-sessions-common/src/test/java/org/eclipse/jetty/server/session/CreationTest.java +++ b/tests/test-sessions/test-sessions-common/src/test/java/org/eclipse/jetty/server/session/CreationTest.java @@ -107,8 +107,6 @@ public class CreationTest String sessionCookie = response.getHeaders().get("Set-Cookie"); assertTrue(sessionCookie != null); - // Mangle the cookie, replacing Path with $Path, etc. - sessionCookie = sessionCookie.replaceFirst("(\\W)(P|p)ath=", "$1\\$Path="); //session should now be evicted from the cache String id = TestServer.extractSessionId(sessionCookie); @@ -118,7 +116,6 @@ public class CreationTest //make another request for the same session Request request = client.newRequest("http://localhost:" + port1 + contextPath + servletMapping + "?action=test"); - request.header("Cookie", sessionCookie); response = request.send(); assertEquals(HttpServletResponse.SC_OK,response.getStatus()); diff --git a/tests/test-sessions/test-sessions-common/src/test/java/org/eclipse/jetty/server/session/DirtyAttributeTest.java b/tests/test-sessions/test-sessions-common/src/test/java/org/eclipse/jetty/server/session/DirtyAttributeTest.java index 7fd488d078b..6790ca15749 100644 --- a/tests/test-sessions/test-sessions-common/src/test/java/org/eclipse/jetty/server/session/DirtyAttributeTest.java +++ b/tests/test-sessions/test-sessions-common/src/test/java/org/eclipse/jetty/server/session/DirtyAttributeTest.java @@ -112,12 +112,9 @@ public class DirtyAttributeTest assertEquals(HttpServletResponse.SC_OK,response.getStatus()); String sessionCookie = response.getHeaders().get("Set-Cookie"); assertTrue(sessionCookie != null); - // Mangle the cookie, replacing Path with $Path, etc. - sessionCookie = sessionCookie.replaceFirst("(\\W)(P|p)ath=", "$1\\$Path="); - + //do another request to change the session attribute Request request = client.newRequest("http://localhost:" + port + "/mod/test?action=setA"); - request.header("Cookie", sessionCookie); response = request.send(); assertEquals(HttpServletResponse.SC_OK,response.getStatus()); @@ -128,7 +125,6 @@ public class DirtyAttributeTest //do another request using the cookie to try changing the session attribute to the same value again request= client.newRequest("http://localhost:" + port + "/mod/test?action=setA"); - request.header("Cookie", sessionCookie); response = request.send(); assertEquals(HttpServletResponse.SC_OK,response.getStatus()); A_VALUE.assertPassivatesEquals(2); @@ -138,7 +134,6 @@ public class DirtyAttributeTest //do another request using the cookie and change to a different value request= client.newRequest("http://localhost:" + port + "/mod/test?action=setB"); - request.header("Cookie", sessionCookie); response = request.send(); assertEquals(HttpServletResponse.SC_OK,response.getStatus()); B_VALUE.assertPassivatesEquals(1); diff --git a/tests/test-sessions/test-sessions-common/src/test/java/org/eclipse/jetty/server/session/IdleSessionTest.java b/tests/test-sessions/test-sessions-common/src/test/java/org/eclipse/jetty/server/session/IdleSessionTest.java index ec110cac542..b3f52588fc2 100644 --- a/tests/test-sessions/test-sessions-common/src/test/java/org/eclipse/jetty/server/session/IdleSessionTest.java +++ b/tests/test-sessions/test-sessions-common/src/test/java/org/eclipse/jetty/server/session/IdleSessionTest.java @@ -105,8 +105,6 @@ public class IdleSessionTest assertEquals(HttpServletResponse.SC_OK,response.getStatus()); String sessionCookie = response.getHeaders().get("Set-Cookie"); assertTrue(sessionCookie != null); - // Mangle the cookie, replacing Path with $Path, etc. - sessionCookie = sessionCookie.replaceFirst("(\\W)(P|p)ath=", "$1\\$Path="); //and wait until the session should be idled out pause(evictionSec*3); @@ -118,7 +116,6 @@ public class IdleSessionTest //make another request to de-idle the session Request request = client.newRequest(url + "?action=test"); - request.getHeaders().add("Cookie", sessionCookie); ContentResponse response2 = request.send(); assertEquals(HttpServletResponse.SC_OK,response2.getStatus()); @@ -140,7 +137,6 @@ public class IdleSessionTest //make a request request = client.newRequest(url + "?action=testfail"); - request.getHeaders().add("Cookie", sessionCookie); response2 = request.send(); assertEquals(HttpServletResponse.SC_OK,response2.getStatus()); @@ -150,8 +146,6 @@ public class IdleSessionTest assertEquals(HttpServletResponse.SC_OK,response.getStatus()); sessionCookie = response.getHeaders().get("Set-Cookie"); assertTrue(sessionCookie != null); - // Mangle the cookie, replacing Path with $Path, etc. - sessionCookie = sessionCookie.replaceFirst("(\\W)(P|p)ath=", "$1\\$Path="); id = TestServer.extractSessionId(sessionCookie); //and wait until the session should be idled out @@ -170,7 +164,6 @@ public class IdleSessionTest //make another request to de-idle the session request = client.newRequest(url + "?action=testfail"); - request.getHeaders().add("Cookie", sessionCookie); response2 = request.send(); assertEquals(HttpServletResponse.SC_OK,response2.getStatus()); diff --git a/tests/test-sessions/test-sessions-common/src/test/java/org/eclipse/jetty/server/session/ImmortalSessionTest.java b/tests/test-sessions/test-sessions-common/src/test/java/org/eclipse/jetty/server/session/ImmortalSessionTest.java index 374de0aa68c..fcf9dd7cf3e 100644 --- a/tests/test-sessions/test-sessions-common/src/test/java/org/eclipse/jetty/server/session/ImmortalSessionTest.java +++ b/tests/test-sessions/test-sessions-common/src/test/java/org/eclipse/jetty/server/session/ImmortalSessionTest.java @@ -96,8 +96,6 @@ public class ImmortalSessionTest assertEquals(HttpServletResponse.SC_OK,response.getStatus()); String sessionCookie = response.getHeaders().get("Set-Cookie"); assertTrue(sessionCookie != null); - // Mangle the cookie, replacing Path with $Path, etc. - sessionCookie = sessionCookie.replaceFirst("(\\W)(P|p)ath=", "$1\\$Path="); String resp = response.getContentAsString(); assertEquals(resp.trim(),String.valueOf(value)); @@ -107,7 +105,6 @@ public class ImmortalSessionTest // Be sure the session is still there Request request = client.newRequest("http://localhost:" + port + contextPath + servletMapping + "?action=get"); - request.header("Cookie", sessionCookie); response = request.send(); assertEquals(HttpServletResponse.SC_OK,response.getStatus()); diff --git a/tests/test-sessions/test-sessions-common/src/test/java/org/eclipse/jetty/server/session/ReentrantRequestSessionTest.java b/tests/test-sessions/test-sessions-common/src/test/java/org/eclipse/jetty/server/session/ReentrantRequestSessionTest.java index 43707c6b7c3..fa5011e33be 100644 --- a/tests/test-sessions/test-sessions-common/src/test/java/org/eclipse/jetty/server/session/ReentrantRequestSessionTest.java +++ b/tests/test-sessions/test-sessions-common/src/test/java/org/eclipse/jetty/server/session/ReentrantRequestSessionTest.java @@ -72,8 +72,6 @@ public class ReentrantRequestSessionTest String sessionCookie = response.getHeaders().get("Set-Cookie"); assertTrue(sessionCookie != null); - // Mangle the cookie, replacing Path with $Path, etc. - sessionCookie = sessionCookie.replaceFirst("(\\W)(P|p)ath=", "$1\\$Path="); //make a request that will make a simultaneous request for the same session Request request = client.newRequest("http://localhost:" + port + contextPath + servletMapping + "?action=reenter&port=" + port + "&path=" + contextPath + servletMapping); diff --git a/tests/test-sessions/test-sessions-common/src/test/java/org/eclipse/jetty/server/session/RemoveSessionTest.java b/tests/test-sessions/test-sessions-common/src/test/java/org/eclipse/jetty/server/session/RemoveSessionTest.java index 12e37961973..c22c2b4a79b 100644 --- a/tests/test-sessions/test-sessions-common/src/test/java/org/eclipse/jetty/server/session/RemoveSessionTest.java +++ b/tests/test-sessions/test-sessions-common/src/test/java/org/eclipse/jetty/server/session/RemoveSessionTest.java @@ -80,8 +80,7 @@ public class RemoveSessionTest assertEquals(HttpServletResponse.SC_OK,response.getStatus()); String sessionCookie = response.getHeaders().get("Set-Cookie"); assertTrue(sessionCookie != null); - // Mangle the cookie, replacing Path with $Path, etc. - sessionCookie = sessionCookie.replaceFirst("(\\W)(P|p)ath=", "$1\\$Path="); + //ensure sessionCreated listener is called assertTrue (testListener.isCreated()); assertEquals(1, m.getSessionsCreated()); @@ -90,7 +89,6 @@ public class RemoveSessionTest //now delete the session Request request = client.newRequest("http://localhost:" + port + contextPath + servletMapping + "?action=delete"); - request.header("Cookie", sessionCookie); response = request.send(); assertEquals(HttpServletResponse.SC_OK,response.getStatus()); //ensure sessionDestroyed listener is called @@ -104,7 +102,6 @@ public class RemoveSessionTest // The session is not there anymore, even if we present an old cookie request = client.newRequest("http://localhost:" + port + contextPath + servletMapping + "?action=check"); - request.header("Cookie", sessionCookie); response = request.send(); assertEquals(HttpServletResponse.SC_OK,response.getStatus()); assertEquals(0, ((DefaultSessionCache)m.getSessionCache()).getSessionsCurrent()); diff --git a/tests/test-sessions/test-sessions-common/src/test/java/org/eclipse/jetty/server/session/SameContextForwardedSessionTest.java b/tests/test-sessions/test-sessions-common/src/test/java/org/eclipse/jetty/server/session/SameContextForwardedSessionTest.java index 8040f11e7e3..f63c7a35b75 100644 --- a/tests/test-sessions/test-sessions-common/src/test/java/org/eclipse/jetty/server/session/SameContextForwardedSessionTest.java +++ b/tests/test-sessions/test-sessions-common/src/test/java/org/eclipse/jetty/server/session/SameContextForwardedSessionTest.java @@ -93,8 +93,6 @@ public class SameContextForwardedSessionTest assertEquals(HttpServletResponse.SC_OK, response.getStatus()); String sessionCookie = response.getHeaders().get("Set-Cookie"); assertTrue(sessionCookie != null); - // Mangle the cookie, replacing Path with $Path, etc. - sessionCookie = sessionCookie.replaceFirst("(\\W)(P|p)ath=", "$1\\$Path="); //wait until all of the request handling has finished _synchronizer.await(); @@ -105,7 +103,6 @@ public class SameContextForwardedSessionTest //Make a fresh request Request request = client.newRequest("http://localhost:" + serverPort + "/context/four"); - request.header("Cookie", sessionCookie); response = request.send(); assertEquals(HttpServletResponse.SC_OK, response.getStatus()); diff --git a/tests/test-sessions/test-sessions-common/src/test/java/org/eclipse/jetty/server/session/SameNodeLoadTest.java b/tests/test-sessions/test-sessions-common/src/test/java/org/eclipse/jetty/server/session/SameNodeLoadTest.java index bbbea552ee2..3720f75ea76 100644 --- a/tests/test-sessions/test-sessions-common/src/test/java/org/eclipse/jetty/server/session/SameNodeLoadTest.java +++ b/tests/test-sessions/test-sessions-common/src/test/java/org/eclipse/jetty/server/session/SameNodeLoadTest.java @@ -83,8 +83,6 @@ public class SameNodeLoadTest assertEquals(HttpServletResponse.SC_OK,response1.getStatus()); String sessionCookie = response1.getHeaders().get("Set-Cookie"); assertTrue(sessionCookie != null); - // Mangle the cookie, replacing Path with $Path, etc. - sessionCookie = sessionCookie.replaceFirst("(\\W)(P|p)ath=", "$1\\$Path="); //simulate 10 clients making 100 requests each ExecutorService executor = Executors.newCachedThreadPool(); @@ -110,7 +108,6 @@ public class SameNodeLoadTest // Perform one request to get the result Request request = client.newRequest( url + "?action=result" ); - request.header("Cookie", sessionCookie); ContentResponse response2 = request.send(); assertEquals(HttpServletResponse.SC_OK,response2.getStatus()); String response = response2.getContentAsString(); @@ -174,7 +171,6 @@ public class SameNodeLoadTest Thread.currentThread().sleep(pauseMsec); } Request request = client.newRequest(url + "?action=increment"); - request.header("Cookie", sessionCookie); ContentResponse response = request.send(); assertEquals(HttpServletResponse.SC_OK,response.getStatus()); } diff --git a/tests/test-sessions/test-sessions-common/src/test/java/org/eclipse/jetty/server/session/SaveOptimizeTest.java b/tests/test-sessions/test-sessions-common/src/test/java/org/eclipse/jetty/server/session/SaveOptimizeTest.java index 3c9e6549fa1..3b1f47dac95 100644 --- a/tests/test-sessions/test-sessions-common/src/test/java/org/eclipse/jetty/server/session/SaveOptimizeTest.java +++ b/tests/test-sessions/test-sessions-common/src/test/java/org/eclipse/jetty/server/session/SaveOptimizeTest.java @@ -159,11 +159,8 @@ public class SaveOptimizeTest //make a few requests to access the session but not change it for (int i=0;i<5; i++) { - sessionCookie = sessionCookie.replaceFirst("(\\W)(P|p)ath=", "$1\\$Path="); - // Perform a request to contextB with the same session cookie Request request = client.newRequest("http://localhost:" + port1 + contextPath + servletMapping+"?action=noop"); - request.header("Cookie", sessionCookie); response = request.send(); //check session is unchanged @@ -237,9 +234,7 @@ public class SaveOptimizeTest // Perform a request to do nothing with the same session cookie - sessionCookie = sessionCookie.replaceFirst("(\\W)(P|p)ath=", "$1\\$Path="); Request request = client.newRequest("http://localhost:" + port1 + contextPath + servletMapping+"?action=noop"); - request.header("Cookie", sessionCookie); response = request.send(); //check session not saved @@ -249,7 +244,6 @@ public class SaveOptimizeTest // Perform a request to mutate the session request = client.newRequest("http://localhost:" + port1 + contextPath + servletMapping+"?action=mutate"); - request.header("Cookie", sessionCookie); response = request.send(); //check session is saved @@ -316,11 +310,9 @@ public class SaveOptimizeTest long lastSaved = data.getLastSaved(); //make another request, session should not change - sessionCookie = sessionCookie.replaceFirst("(\\W)(P|p)ath=", "$1\\$Path="); // Perform a request to do nothing with the same session cookie Request request = client.newRequest("http://localhost:" + port1 + contextPath + servletMapping+"?action=noop"); - request.header("Cookie", sessionCookie); response = request.send(); //check session not saved @@ -333,7 +325,6 @@ public class SaveOptimizeTest // Perform a request to do nothing with the same session cookie request = client.newRequest("http://localhost:" + port1 + contextPath + servletMapping+"?action=noop"); - request.header("Cookie", sessionCookie); response = request.send(); //check session is saved @@ -401,12 +392,8 @@ public class SaveOptimizeTest long lastSaved = data.getLastSaved(); assertTrue(lastSaved > 0); //check session created was saved - - sessionCookie = sessionCookie.replaceFirst("(\\W)(P|p)ath=", "$1\\$Path="); - // Perform a request to do nothing with the same session cookie, check the session object is different Request request = client.newRequest("http://localhost:" + port1 + contextPath + servletMapping+"?action=noop&check=diff"); - request.header("Cookie", sessionCookie); response = request.send(); //check session not saved @@ -476,12 +463,8 @@ public class SaveOptimizeTest long lastSaved = data.getLastSaved(); assertTrue(lastSaved > 0); //check session created was saved - - sessionCookie = sessionCookie.replaceFirst("(\\W)(P|p)ath=", "$1\\$Path="); - // Perform a request to change maxInactive on session Request request = client.newRequest("http://localhost:" + port1 + contextPath + servletMapping+"?action=max&value=60"); - request.header("Cookie", sessionCookie); response = request.send(); //check session is saved, even though the save optimisation interval has not passed diff --git a/tests/test-sessions/test-sessions-common/src/test/java/org/eclipse/jetty/server/session/SessionEvictionFailureTest.java b/tests/test-sessions/test-sessions-common/src/test/java/org/eclipse/jetty/server/session/SessionEvictionFailureTest.java index d21b9493af2..fba4a6cdc36 100644 --- a/tests/test-sessions/test-sessions-common/src/test/java/org/eclipse/jetty/server/session/SessionEvictionFailureTest.java +++ b/tests/test-sessions/test-sessions-common/src/test/java/org/eclipse/jetty/server/session/SessionEvictionFailureTest.java @@ -237,9 +237,7 @@ public class SessionEvictionFailureTest assertEquals(HttpServletResponse.SC_OK,response.getStatus()); String sessionCookie = response.getHeaders().get("Set-Cookie"); assertNotNull(sessionCookie); - // Mangle the cookie, replacing Path with $Path, etc. - sessionCookie = sessionCookie.replaceFirst("(\\W)(P|p)ath=", "$1\\$Path="); - + //Wait for the eviction period to expire - save on evict should fail but session //should remain in the cache pause(evictionPeriod+(int)(evictionPeriod*0.5)); @@ -248,7 +246,6 @@ public class SessionEvictionFailureTest // Make another request to see if the session is still in the cache and can be used, //allow it to be saved this time Request request = client.newRequest(url + "?action=test"); - request.header("Cookie", sessionCookie); response = request.send(); assertEquals(HttpServletResponse.SC_OK,response.getStatus()); assertNull(response.getHeaders().get("Set-Cookie")); //check that the cookie wasn't reset @@ -259,7 +256,6 @@ public class SessionEvictionFailureTest request = client.newRequest(url + "?action=test"); - request.header("Cookie", sessionCookie); response = request.send(); assertEquals(HttpServletResponse.SC_OK,response.getStatus()); } diff --git a/tests/test-sessions/test-sessions-common/src/test/java/org/eclipse/jetty/server/session/SessionListenerTest.java b/tests/test-sessions/test-sessions-common/src/test/java/org/eclipse/jetty/server/session/SessionListenerTest.java index 9baaea02fdc..b94f8d5cd51 100644 --- a/tests/test-sessions/test-sessions-common/src/test/java/org/eclipse/jetty/server/session/SessionListenerTest.java +++ b/tests/test-sessions/test-sessions-common/src/test/java/org/eclipse/jetty/server/session/SessionListenerTest.java @@ -109,15 +109,11 @@ public class SessionListenerTest assertEquals(HttpServletResponse.SC_OK,response1.getStatus()); String sessionCookie = response1.getHeaders().get("Set-Cookie"); assertTrue(sessionCookie != null); - // Mangle the cookie, replacing Path with $Path, etc. - sessionCookie = sessionCookie.replaceFirst("(\\W)(P|p)ath=", "$1\\$Path="); - assertTrue (servlet.listener.bound); // Make a request which will invalidate the existing session Request request2 = client.newRequest(url + "?action=test"); - request2.header("Cookie", sessionCookie); ContentResponse response2 = request2.send(); assertEquals(HttpServletResponse.SC_OK,response2.getStatus()); diff --git a/tests/test-sessions/test-sessions-common/src/test/java/org/eclipse/jetty/server/session/SessionRenewTest.java b/tests/test-sessions/test-sessions-common/src/test/java/org/eclipse/jetty/server/session/SessionRenewTest.java index ed2909130f2..3b663083aee 100644 --- a/tests/test-sessions/test-sessions-common/src/test/java/org/eclipse/jetty/server/session/SessionRenewTest.java +++ b/tests/test-sessions/test-sessions-common/src/test/java/org/eclipse/jetty/server/session/SessionRenewTest.java @@ -135,7 +135,6 @@ public class SessionRenewTest //make a request to change the sessionid Request request = client.newRequest("http://localhost:" + port + contextPath + servletMapping + "?action=renew"); - request.header("Cookie", sessionCookie); ContentResponse renewResponse = request.send(); assertEquals(HttpServletResponse.SC_OK,renewResponse.getStatus());