Author: markt
Date: Wed Oct 29 17:55:12 2014
New Revision: 1635228
URL: http://svn.apache.org/r1635228
Log:
Add a simple test of the normalization method
Modified:
tomcat/trunk/test/org/apache/catalina/connector/TestCoyoteAdapter.java
Modified: tomcat/trunk/test/org/apache/catalina/connector/TestCoyoteAdapter.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/catalina/connector/TestCoyoteAdapter.java?rev=1635228&r1=1635227&r2=1635228&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/catalina/connector/TestCoyoteAdapter.java
(original)
+++ tomcat/trunk/test/org/apache/catalina/connector/TestCoyoteAdapter.java Wed
Oct 29 17:55:12 2014
@@ -37,6 +37,7 @@ import org.apache.catalina.startup.Simpl
import org.apache.catalina.startup.Tomcat;
import org.apache.catalina.startup.TomcatBaseTest;
import org.apache.tomcat.util.buf.ByteChunk;
+import org.apache.tomcat.util.buf.MessageBytes;
public class TestCoyoteAdapter extends TomcatBaseTest {
@@ -325,6 +326,28 @@ public class TestCoyoteAdapter extends T
Assert.assertTrue(servlet.isCompleted());
}
+ @Test
+ public void testNormalize01() {
+ doTestNormalize("/foo/../bar", "/bar");
+ }
+
+ private void doTestNormalize(String input, String expected) {
+ MessageBytes mb = MessageBytes.newInstance();
+ byte[] b = input.getBytes(StandardCharsets.UTF_8);
+ mb.setBytes(b, 0, b.length);
+
+ boolean result = CoyoteAdapter.normalize(mb);
+ mb.toString();
+
+ if (expected == null) {
+ Assert.assertFalse(result);
+ } else {
+ Assert.assertTrue(result);
+ Assert.assertEquals(expected, mb.toString());
+ }
+ }
+
+
private class AsyncServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]