tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jboy...@apache.org
Subject svn commit: r1557017 - in /tomcat/trunk/test/org/apache/tomcat/util/http: TestSetCookieSupport.java TestSetCookieSupportSeparatorsAllowed.java
Date Fri, 10 Jan 2014 03:08:31 GMT
Author: jboynes
Date: Fri Jan 10 03:08:28 2014
New Revision: 1557017

URL: http://svn.apache.org/r1557017
Log:
add tests for setting v1 cookie values

Modified:
    tomcat/trunk/test/org/apache/tomcat/util/http/TestSetCookieSupport.java
    tomcat/trunk/test/org/apache/tomcat/util/http/TestSetCookieSupportSeparatorsAllowed.java

Modified: tomcat/trunk/test/org/apache/tomcat/util/http/TestSetCookieSupport.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/tomcat/util/http/TestSetCookieSupport.java?rev=1557017&r1=1557016&r2=1557017&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/tomcat/util/http/TestSetCookieSupport.java (original)
+++ tomcat/trunk/test/org/apache/tomcat/util/http/TestSetCookieSupport.java Fri Jan 10 03:08:28
2014
@@ -33,6 +33,7 @@ public class TestSetCookieSupport {
     @Test
     public void v0NullValue() {
         Cookie cookie = new Cookie("foo", null);
+        // should this throw an IAE?
 //        Assert.assertEquals("foo=", SetCookieSupport.generateHeader(cookie));
         Assert.assertEquals("foo=\"\"", SetCookieSupport.generateHeader(cookie));
     }
@@ -109,4 +110,95 @@ public class TestSetCookieSupport {
 //        Assert.assertEquals("foo=a\"b\\c", SetCookieSupport.generateHeader(cookie));
         Assert.assertEquals("foo=\"a\\\"b\\\\c\"; Version=1", SetCookieSupport.generateHeader(cookie));
     }
+
+    @Test
+    public void v1simpleCookie() {
+        Cookie cookie = new Cookie("foo", "bar");
+        cookie.setVersion(1);
+        Assert.assertEquals("foo=bar; Version=1", SetCookieSupport.generateHeader(cookie));
+    }
+
+    @Test
+    public void v1NullValue() {
+        Cookie cookie = new Cookie("foo", null);
+        cookie.setVersion(1);
+        // should this throw an IAE?
+        Assert.assertEquals("foo=\"\"; Version=1", SetCookieSupport.generateHeader(cookie));
+    }
+
+    @Test
+    public void v1QuotedValue() {
+        Cookie cookie = new Cookie("foo", "\"bar\"");
+        cookie.setVersion(1);
+        // should this be escaping the quotes rather than passing through?
+        Assert.assertEquals("foo=\"bar\"; Version=1", SetCookieSupport.generateHeader(cookie));
+    }
+
+    @Test
+    public void v1ValueContainsSemicolon() {
+        Cookie cookie = new Cookie("foo", "a;b");
+        cookie.setVersion(1);
+        // should this be throwing IAE rather than adding quotes?
+        Assert.assertEquals("foo=\"a;b\"; Version=1", SetCookieSupport.generateHeader(cookie));
+    }
+
+    @Test
+    public void v1ValueContainsComma() {
+        Cookie cookie = new Cookie("foo", "a,b");
+        cookie.setVersion(1);
+        // should this be throwing IAE rather than adding quotes?
+        Assert.assertEquals("foo=\"a,b\"; Version=1", SetCookieSupport.generateHeader(cookie));
+    }
+
+    @Test
+    public void v1ValueContainsSpace() {
+        Cookie cookie = new Cookie("foo", "a b");
+        cookie.setVersion(1);
+        // should this be throwing IAE rather than adding quotes?
+        Assert.assertEquals("foo=\"a b\"; Version=1", SetCookieSupport.generateHeader(cookie));
+    }
+
+    @Test
+    public void v1ValueContainsEquals() {
+        Cookie cookie = new Cookie("foo", "a=b");
+        cookie.setVersion(1);
+        // should this be throwing IAE rather than adding quotes?
+        Assert.assertEquals("foo=\"a=b\"; Version=1", SetCookieSupport.generateHeader(cookie));
+    }
+
+    @Test
+    public void v1ValueContainsQuote() {
+        Cookie cookie = new Cookie("foo", "a\"b");
+        cookie.setVersion(1);
+        // should this be throwing IAE rather than adding quotes?
+        Assert.assertEquals("foo=\"a\\\"b\"; Version=1", SetCookieSupport.generateHeader(cookie));
+    }
+
+    @Ignore("bug 55975")
+    @Test
+    public void v1ValueContainsNonV0Separator() {
+        Cookie cookie = new Cookie("foo", "a()<>@,;:\\\"/[]?={}b");
+        cookie.setVersion(1);
+        // should this be throwing IAE rather than adding quotes?
+        Assert.assertEquals("foo=\"a()<>@,;:\\\\\\\"/[]?={}b\"; Version=1", SetCookieSupport.generateHeader(cookie));
+    }
+
+    @Ignore("bug 55975")
+    @Test
+    public void v1ValueContainsBackslash() {
+        Cookie cookie = new Cookie("foo", "a\\b");
+        cookie.setVersion(1);
+        // should this be throwing IAE rather than adding quotes?
+        Assert.assertEquals("foo=\"a\\\\b\"; Version=1", SetCookieSupport.generateHeader(cookie));
+    }
+
+
+    @Ignore("bug 55975")
+    @Test
+    public void v1ValueContainsBackslashAndQuote() {
+        Cookie cookie = new Cookie("foo", "a\"b\\c");
+        cookie.setVersion(1);
+        // should this be throwing IAE rather than adding quotes?
+        Assert.assertEquals("foo=\"a\\\"b\\\\c\"; Version=1", SetCookieSupport.generateHeader(cookie));
+    }
 }

Modified: tomcat/trunk/test/org/apache/tomcat/util/http/TestSetCookieSupportSeparatorsAllowed.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/tomcat/util/http/TestSetCookieSupportSeparatorsAllowed.java?rev=1557017&r1=1557016&r2=1557017&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/tomcat/util/http/TestSetCookieSupportSeparatorsAllowed.java
(original)
+++ tomcat/trunk/test/org/apache/tomcat/util/http/TestSetCookieSupportSeparatorsAllowed.java
Fri Jan 10 03:08:28 2014
@@ -19,6 +19,7 @@ package org.apache.tomcat.util.http;
 import javax.servlet.http.Cookie;
 
 import org.junit.Assert;
+import org.junit.Ignore;
 import org.junit.Test;
 
 public class TestSetCookieSupportSeparatorsAllowed {
@@ -97,4 +98,97 @@ public class TestSetCookieSupportSeparat
         Cookie cookie = new Cookie("foo", "a\"b\\c");
         Assert.assertEquals("foo=a\"b\\c", SetCookieSupport.generateHeader(cookie));
     }
+
+    @Test
+    public void v1simpleCookie() {
+        Cookie cookie = new Cookie("foo", "bar");
+        cookie.setVersion(1);
+        Assert.assertEquals("foo=bar; Version=1", SetCookieSupport.generateHeader(cookie));
+    }
+
+    @Test
+    public void v1NullValue() {
+        Cookie cookie = new Cookie("foo", null);
+        cookie.setVersion(1);
+        // should this throw an IAE?
+        Assert.assertEquals("foo=\"\"; Version=1", SetCookieSupport.generateHeader(cookie));
+    }
+
+    @Test
+    public void v1QuotedValue() {
+        Cookie cookie = new Cookie("foo", "\"bar\"");
+        cookie.setVersion(1);
+        // should this be escaping the quotes rather than passing through?
+        Assert.assertEquals("foo=\"bar\"; Version=1", SetCookieSupport.generateHeader(cookie));
+    }
+
+    @Test
+    public void v1ValueContainsSemicolon() {
+        Cookie cookie = new Cookie("foo", "a;b");
+        cookie.setVersion(1);
+        // should this be throwing IAE rather than adding quotes?
+        Assert.assertEquals("foo=\"a;b\"; Version=1", SetCookieSupport.generateHeader(cookie));
+    }
+
+    @Test
+    public void v1ValueContainsComma() {
+        Cookie cookie = new Cookie("foo", "a,b");
+        cookie.setVersion(1);
+        // should this be throwing IAE rather than adding quotes?
+        Assert.assertEquals("foo=\"a,b\"; Version=1", SetCookieSupport.generateHeader(cookie));
+    }
+
+    @Test
+    public void v1ValueContainsSpace() {
+        Cookie cookie = new Cookie("foo", "a b");
+        cookie.setVersion(1);
+        // should this be throwing IAE rather than adding quotes?
+        Assert.assertEquals("foo=\"a b\"; Version=1", SetCookieSupport.generateHeader(cookie));
+    }
+
+    @Ignore("bug 55984")
+    @Test
+    public void v1ValueContainsEquals() {
+        Cookie cookie = new Cookie("foo", "a=b");
+        cookie.setVersion(1);
+        // should this be throwing IAE rather than adding quotes?
+        Assert.assertEquals("foo=\"a=b\"; Version=1", SetCookieSupport.generateHeader(cookie));
+    }
+
+    @Ignore("bug 55984")
+    @Test
+    public void v1ValueContainsQuote() {
+        Cookie cookie = new Cookie("foo", "a\"b");
+        cookie.setVersion(1);
+        // should this be throwing IAE rather than adding quotes?
+        Assert.assertEquals("foo=\"a\\\"b\"; Version=1", SetCookieSupport.generateHeader(cookie));
+    }
+
+    @Ignore("bug 55975")
+    @Test
+    public void v1ValueContainsNonV0Separator() {
+        Cookie cookie = new Cookie("foo", "a()<>@,;:\\\"/[]?={}b");
+        cookie.setVersion(1);
+        // should this be throwing IAE rather than adding quotes?
+        Assert.assertEquals("foo=\"a()<>@,;:\\\\\\\"/[]?={}b\"; Version=1", SetCookieSupport.generateHeader(cookie));
+    }
+
+    @Ignore("bug 55975")
+    @Test
+    public void v1ValueContainsBackslash() {
+        Cookie cookie = new Cookie("foo", "a\\b");
+        cookie.setVersion(1);
+        // should this be throwing IAE rather than adding quotes?
+        Assert.assertEquals("foo=\"a\\\\b\"; Version=1", SetCookieSupport.generateHeader(cookie));
+    }
+
+
+    @Ignore("bug 55975")
+    @Test
+    public void v1ValueContainsBackslashAndQuote() {
+        Cookie cookie = new Cookie("foo", "a\"b\\c");
+        cookie.setVersion(1);
+        // should this be throwing IAE rather than adding quotes?
+        Assert.assertEquals("foo=\"a\\\"b\\\\c\"; Version=1", SetCookieSupport.generateHeader(cookie));
+    }
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message