From 363498485efe02782b0af0ca30c7240e2c6050cd Mon Sep 17 00:00:00 2001 From: maxcooper Date: Wed, 15 Feb 2006 09:55:41 +0000 Subject: [PATCH] bug#1056920: renamed unit test class and method names, improved session cookie test to look specifically for JSESSIONID cookie --- ...orUnsecuredTest.java => NoAuthSessionTest.java} | 27 +++++++++++----------- 1 file changed, 14 insertions(+), 13 deletions(-) rename src/test/org/securityfilter/test/http/form/{NoSessionForUnsecuredTest.java => NoAuthSessionTest.java} (79%) diff --git a/src/test/org/securityfilter/test/http/form/NoSessionForUnsecuredTest.java b/src/test/org/securityfilter/test/http/form/NoAuthSessionTest.java similarity index 79% rename from src/test/org/securityfilter/test/http/form/NoSessionForUnsecuredTest.java rename to src/test/org/securityfilter/test/http/form/NoAuthSessionTest.java index 8f3e888..79d2df3 100644 --- a/src/test/org/securityfilter/test/http/form/NoSessionForUnsecuredTest.java +++ b/src/test/org/securityfilter/test/http/form/NoAuthSessionTest.java @@ -59,10 +59,9 @@ import org.securityfilter.test.http.TestBase; import com.meterware.httpunit.GetMethodWebRequest; import com.meterware.httpunit.WebRequest; -import com.meterware.httpunit.WebResponse; /** - * NoSessionForUnsecuredTest - Ensure that SecurityFilter does not create a session when accessing unsecured pages. + * NoAuthSessionTest - Ensure that SecurityFilter does not create a session when accessing unsecured pages. * * Bug report: * http://sourceforge.net/tracker/index.php?func=detail&aid=1056920&group_id=59484&atid=491164 @@ -70,13 +69,13 @@ import com.meterware.httpunit.WebResponse; * @author Max Cooper (max@maxcooper.com) * @version $Revision$ $Date$ */ -public class NoSessionForUnsecuredTest extends TestBase { +public class NoAuthSessionTest extends TestBase { /** * Constructor * * @param name */ - public NoSessionForUnsecuredTest(String name) { + public NoAuthSessionTest(String name) { super(name); } @@ -85,26 +84,28 @@ public class NoSessionForUnsecuredTest extends TestBase { * * @throws Exception */ - public void testNoSessionForUnsecured() throws Exception { + public void testNoAuthSessionForUnsecured() throws Exception { WebRequest request = new GetMethodWebRequest(baseUrl + "/index.jsp"); - WebResponse response = session.getResponse(request); + session.getResponse(request); - String[] cookieNames = response.getNewCookieNames(); - assertEquals("Number of cookies should be 0.", 0, cookieNames.length); + // Check that there is no session ID + String sessionId = session.getCookieValue("JSESSIONID"); + assertNull("Got session for non-authenticated index page", sessionId); } /** - * Test for session cookie on index page. There should be no session cookie. + * Test for session cookie on direct access of login page. There should be no session cookie. * * @throws Exception */ - public void testNoSessionForLoginPage() throws Exception { + public void testNoAuthSessionForLoginPage() throws Exception { WebRequest request = new GetMethodWebRequest(baseUrl + "/loginForm.jsp"); - WebResponse response = session.getResponse(request); + session.getResponse(request); - String[] cookieNames = response.getNewCookieNames(); - assertEquals("Number of cookies should be 0.", 0, cookieNames.length); + // Check that there is no session ID + String sessionId = session.getCookieValue("JSESSIONID"); + assertNull("Got session for non-authenticated login page", sessionId); } } -- 2.11.0