Test some edge cases with = in cookie values (current code fails these tests - patch...
authormarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Tue, 17 Nov 2009 20:48:15 +0000 (20:48 +0000)
committermarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Tue, 17 Nov 2009 20:48:15 +0000 (20:48 +0000)
git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@881499 13f79535-47bb-0310-9956-ffa450edef68

test/org/apache/tomcat/util/http/TestCookiesAllowEquals.java

index 9445b4b..f58a53d 100644 (file)
@@ -31,7 +31,9 @@ import org.apache.catalina.startup.Tomcat;
 
 public class TestCookiesAllowEquals extends TomcatBaseTest{
 
-    private static final String COOKIE_WITH_EQUALS = "name=value=withequals";
+    private static final String COOKIE_WITH_EQUALS_1 = "name=equals=middle";
+    private static final String COOKIE_WITH_EQUALS_2 = "name==equalsstart";
+    private static final String COOKIE_WITH_EQUALS_3 = "name=equalsend=";
     
     public void testWithEquals() throws Exception {
         System.setProperty(
@@ -59,7 +61,9 @@ public class TestCookiesAllowEquals extends TomcatBaseTest{
             String[] request = new String[1];
             request[0] =
                 "GET /test HTTP/1.0" + CRLF +
-                "Cookie: " + COOKIE_WITH_EQUALS + CRLF + CRLF;
+                "Cookie: " + COOKIE_WITH_EQUALS_1 + CRLF +
+                "Cookie: " + COOKIE_WITH_EQUALS_2 + CRLF +
+                "Cookie: " + COOKIE_WITH_EQUALS_3 + CRLF + CRLF;
             setRequest(request);
             processRequest(true); // blocks until response has been read
             String response = getResponseBody();
@@ -68,7 +72,8 @@ public class TestCookiesAllowEquals extends TomcatBaseTest{
             disconnect();
             reset();
             tomcat.stop();
-            assertEquals(COOKIE_WITH_EQUALS, response);
+            assertEquals(COOKIE_WITH_EQUALS_1 + COOKIE_WITH_EQUALS_2 +
+                    COOKIE_WITH_EQUALS_3, response);
         }
         
         @Override
@@ -89,7 +94,7 @@ public class TestCookiesAllowEquals extends TomcatBaseTest{
             Cookie cookies[] = req.getCookies();
             for (Cookie cookie : cookies) {
                 resp.getWriter().write(cookie.getName() + "=" +
-                        cookie.getValue() + "\n");
+                        cookie.getValue());
             }
             resp.flushBuffer();
         }