Add unit tests for blank/null cookie names
authormarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Sun, 1 Nov 2009 23:05:26 +0000 (23:05 +0000)
committermarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Sun, 1 Nov 2009 23:05:26 +0000 (23:05 +0000)
git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@831780 13f79535-47bb-0310-9956-ffa450edef68

test/org/apache/tomcat/util/http/CookiesBaseTest.java
test/org/apache/tomcat/util/http/TestCookiesDefaultSysProps.java
test/org/apache/tomcat/util/http/TestCookiesNoFwdStrictSysProps.java
test/org/apache/tomcat/util/http/TestCookiesNoStrictNamingSysProps.java
test/org/apache/tomcat/util/http/TestCookiesStrictSysProps.java
test/org/apache/tomcat/util/http/TestCookiesSwitchSysProps.java

index e6ad383..d19eb73 100644 (file)
@@ -72,6 +72,10 @@ public abstract class CookiesBaseTest extends TomcatBaseTest {
 
         Tomcat.addServlet(ctx, "invalid", new CookieServlet("na;me", "value"));
         ctx.addServletMapping("/invalid", "invalid");
+        Tomcat.addServlet(ctx, "null", new CookieServlet(null, "value"));
+        ctx.addServletMapping("/null", "null");
+        Tomcat.addServlet(ctx, "blank", new CookieServlet("", "value"));
+        ctx.addServletMapping("/blank", "blank");
         Tomcat.addServlet(ctx, "invalidFwd",
                 new CookieServlet("na/me", "value"));
         ctx.addServletMapping("/invalidFwd", "invalidFwd");
index c77ddbb..6f21116 100644 (file)
@@ -43,6 +43,10 @@ public class TestCookiesDefaultSysProps extends CookiesBaseTest {
         
         ByteChunk res = getUrl("http://localhost:" + getPort() + "/invalid");
         assertEquals("Cookie name fail", res.toString());
+        res = getUrl("http://localhost:" + getPort() + "/null");
+        assertEquals("Cookie name fail", res.toString());
+        res = getUrl("http://localhost:" + getPort() + "/blank");
+        assertEquals("Cookie name fail", res.toString());
         res = getUrl("http://localhost:" + getPort() + "/invalidFwd");
         assertEquals("Cookie name ok", res.toString());
         res = getUrl("http://localhost:" + getPort() + "/invalidStrict");
index 4db0cc0..d717a00 100644 (file)
@@ -43,6 +43,10 @@ public class TestCookiesNoFwdStrictSysProps extends CookiesBaseTest {
         
         ByteChunk res = getUrl("http://localhost:" + getPort() + "/invalid");
         assertEquals("Cookie name fail", res.toString());
+        res = getUrl("http://localhost:" + getPort() + "/null");
+        assertEquals("Cookie name fail", res.toString());
+        res = getUrl("http://localhost:" + getPort() + "/blank");
+        assertEquals("Cookie name fail", res.toString());
         res = getUrl("http://localhost:" + getPort() + "/invalidFwd");
         assertEquals("Cookie name ok", res.toString());
         res = getUrl("http://localhost:" + getPort() + "/invalidStrict");
index b353445..0a21982 100644 (file)
@@ -44,6 +44,10 @@ public class TestCookiesNoStrictNamingSysProps extends CookiesBaseTest {
         
         ByteChunk res = getUrl("http://localhost:" + getPort() + "/invalid");
         assertEquals("Cookie name fail", res.toString());
+        res = getUrl("http://localhost:" + getPort() + "/null");
+        assertEquals("Cookie name fail", res.toString());
+        res = getUrl("http://localhost:" + getPort() + "/blank");
+        assertEquals("Cookie name fail", res.toString());
         res = getUrl("http://localhost:" + getPort() + "/invalidFwd");
         assertEquals("Cookie name ok", res.toString());
         res = getUrl("http://localhost:" + getPort() + "/invalidStrict");
index a844195..4da3cdf 100644 (file)
@@ -46,6 +46,10 @@ public class TestCookiesStrictSysProps extends CookiesBaseTest {
         
         ByteChunk res = getUrl("http://localhost:" + getPort() + "/invalid");
         assertEquals("Cookie name fail", res.toString());
+        res = getUrl("http://localhost:" + getPort() + "/null");
+        assertEquals("Cookie name fail", res.toString());
+        res = getUrl("http://localhost:" + getPort() + "/blank");
+        assertEquals("Cookie name fail", res.toString());
         res = getUrl("http://localhost:" + getPort() + "/invalidFwd");
         assertEquals("Cookie name fail", res.toString());
         res = getUrl("http://localhost:" + getPort() + "/invalidStrict");
index d61a71b..9e2c6ce 100644 (file)
@@ -49,6 +49,10 @@ public class TestCookiesSwitchSysProps extends CookiesBaseTest {
         
         ByteChunk res = getUrl("http://localhost:" + getPort() + "/invalid");
         assertEquals("Cookie name fail", res.toString());
+        res = getUrl("http://localhost:" + getPort() + "/null");
+        assertEquals("Cookie name fail", res.toString());
+        res = getUrl("http://localhost:" + getPort() + "/blank");
+        assertEquals("Cookie name fail", res.toString());
         res = getUrl("http://localhost:" + getPort() + "/invalidFwd");
         assertEquals("Cookie name fail", res.toString());
         res = getUrl("http://localhost:" + getPort() + "/invalidStrict");