From: markt Date: Sun, 1 Nov 2009 23:05:26 +0000 (+0000) Subject: Add unit tests for blank/null cookie names X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=48512a3845ac589700eb0326bd43d2ff0e9e8392;p=tomcat7.0 Add unit tests for blank/null cookie names git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@831780 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/test/org/apache/tomcat/util/http/CookiesBaseTest.java b/test/org/apache/tomcat/util/http/CookiesBaseTest.java index e6ad38369..d19eb73cc 100644 --- a/test/org/apache/tomcat/util/http/CookiesBaseTest.java +++ b/test/org/apache/tomcat/util/http/CookiesBaseTest.java @@ -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"); diff --git a/test/org/apache/tomcat/util/http/TestCookiesDefaultSysProps.java b/test/org/apache/tomcat/util/http/TestCookiesDefaultSysProps.java index c77ddbb3f..6f21116f0 100644 --- a/test/org/apache/tomcat/util/http/TestCookiesDefaultSysProps.java +++ b/test/org/apache/tomcat/util/http/TestCookiesDefaultSysProps.java @@ -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"); diff --git a/test/org/apache/tomcat/util/http/TestCookiesNoFwdStrictSysProps.java b/test/org/apache/tomcat/util/http/TestCookiesNoFwdStrictSysProps.java index 4db0cc03e..d717a0080 100644 --- a/test/org/apache/tomcat/util/http/TestCookiesNoFwdStrictSysProps.java +++ b/test/org/apache/tomcat/util/http/TestCookiesNoFwdStrictSysProps.java @@ -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"); diff --git a/test/org/apache/tomcat/util/http/TestCookiesNoStrictNamingSysProps.java b/test/org/apache/tomcat/util/http/TestCookiesNoStrictNamingSysProps.java index b35344525..0a219829e 100644 --- a/test/org/apache/tomcat/util/http/TestCookiesNoStrictNamingSysProps.java +++ b/test/org/apache/tomcat/util/http/TestCookiesNoStrictNamingSysProps.java @@ -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"); diff --git a/test/org/apache/tomcat/util/http/TestCookiesStrictSysProps.java b/test/org/apache/tomcat/util/http/TestCookiesStrictSysProps.java index a844195f8..4da3cdfd1 100644 --- a/test/org/apache/tomcat/util/http/TestCookiesStrictSysProps.java +++ b/test/org/apache/tomcat/util/http/TestCookiesStrictSysProps.java @@ -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"); diff --git a/test/org/apache/tomcat/util/http/TestCookiesSwitchSysProps.java b/test/org/apache/tomcat/util/http/TestCookiesSwitchSysProps.java index d61a71b4e..9e2c6cedf 100644 --- a/test/org/apache/tomcat/util/http/TestCookiesSwitchSysProps.java +++ b/test/org/apache/tomcat/util/http/TestCookiesSwitchSysProps.java @@ -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");