You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2008/11/16 01:30:19 UTC

svn commit: r717950 - in /tomcat/trunk/test: build.xml org/apache/catalina/tomcat/util/http/TestCookies.java

Author: markt
Date: Sat Nov 15 16:30:19 2008
New Revision: 717950

URL: http://svn.apache.org/viewvc?rev=717950&view=rev
Log:
Add jfclere's cookie test fixes to trunk. Merge of r633793.

Modified:
    tomcat/trunk/test/build.xml
    tomcat/trunk/test/org/apache/catalina/tomcat/util/http/TestCookies.java

Modified: tomcat/trunk/test/build.xml
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/build.xml?rev=717950&r1=717949&r2=717950&view=diff
==============================================================================
--- tomcat/trunk/test/build.xml (original)
+++ tomcat/trunk/test/build.xml Sat Nov 15 16:30:19 2008
@@ -28,6 +28,7 @@
   <property name="tomcat.build" value="${basedir}/../output/build"/>
 
   <property name="compile.source" value="1.5"/>
+  <property name="compile.debug" value="true"/>
 
   <property name="junit.jar" value="${junit.home}/junit.jar"/>
   <property name="test.runner" value="junit.textui.TestRunner"/>
@@ -61,7 +62,7 @@
 
   <target name="all" depends="compile">
      <java dir="${test.classes}" classname="${test.runner}" fork="yes" failonerror="${test.failonerror}">
-            <arg value="TestCookies"/>
+            <arg value="org.apache.catalina.tomcat.util.http.TestCookies"/>
             <classpath refid="tomcat.test.classpath"/>
         </java>
 

Modified: tomcat/trunk/test/org/apache/catalina/tomcat/util/http/TestCookies.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/catalina/tomcat/util/http/TestCookies.java?rev=717950&r1=717949&r2=717950&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/catalina/tomcat/util/http/TestCookies.java (original)
+++ tomcat/trunk/test/org/apache/catalina/tomcat/util/http/TestCookies.java Sat Nov 15 16:30:19 2008
@@ -15,7 +15,7 @@
  *  limitations under the License.
  */
 
-package org.apache.catalina.tomcat.util.http;
+package org.apache.catalina.tomcat.util.http; 
 
 import org.apache.tomcat.util.http.Cookies;
 import org.apache.tomcat.util.http.ServerCookie;
@@ -71,8 +71,8 @@
         test("$Version=1;foo=\"bar\";$Domain=apache.org;$Port=8080;a=b", "foo", "bar", "a", "b");
 
         // make sure these never split into two cookies - JVK
-        test("$Version=1;foo=\"b\"ar\";$Domain=apache.org;$Port=8080;a=b",  "foo", "b", "a", "b");
-        test("$Version=1;foo=\"b\\\"ar\";$Domain=apache.org;$Port=8080;a=b", "foo", "b\\\"ar", "a", "b");
+        test("$Version=1;foo=\"b\"ar\";$Domain=apache.org;$Port=8080;a=b",  "foo", "b", "a", "b"); // Incorrectly escaped.
+        test("$Version=1;foo=\"b\\\"ar\";$Domain=apache.org;$Port=8080;a=b", "foo", "b\"ar", "a", "b"); // correctly escaped.
         test("$Version=1;foo=\"b'ar\";$Domain=apache.org;$Port=8080;a=b", "foo", "b'ar", "a", "b");
         // JFC: sure it is "b" and not b'ar ?
         test("$Version=1;foo=b'ar;$Domain=apache.org;$Port=8080;a=b", "foo", "b", "a", "b");
@@ -115,8 +115,28 @@
 
         
         test("foo;a=b;;\\;bar=rab", "foo", "", "a", "b", "bar", "rab");
+
+        // Try all the separators of version1 in version0 cookie.
+        // Won't work we only parse version1 cookie result 1 cookie.
+        test("a=()<>@:\\\"/[]?={}\t; foo=bar", "foo", "bar");
+
+        // Test the version.
+        test("$Version=1;foo=bar", 1);
+        test("$Version=0;foo=bar", 0);
     }
 
+    public static void test( String s, int val ) throws Exception {
+        System.out.println("Processing [" + s + "]");
+        Cookies cs=new Cookies(null);
+        cs.processCookieHeader( s.getBytes(), 0, s.length());
+        int num = cs.getCookieCount();
+        if (num != 1)
+          throw new Exception("wrong number of cookies " + num);
+        ServerCookie co = cs.getCookie(0);
+        System.out.println("One Cookie: " + co);
+        if (co.getVersion() != val)
+          throw new Exception("wrong version " + co.getVersion() + " != " + val);
+    }
     public static void test( String s ) throws Exception {
         System.out.println("Processing [" + s + "]");
         Cookies cs=new Cookies(null);



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