From 94f0f295400f1cdb85d91b3ca0c1697a65df9c69 Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Thu, 22 Jan 2015 12:41:13 +0100 Subject: [PATCH 1/2] 458101 added test for maxFormContentSize --- .../org/eclipse/jetty/server/RequestTest.java | 48 ++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/RequestTest.java b/jetty-server/src/test/java/org/eclipse/jetty/server/RequestTest.java index f3d6febc3ce..307d5dd339b 100644 --- a/jetty-server/src/test/java/org/eclipse/jetty/server/RequestTest.java +++ b/jetty-server/src/test/java/org/eclipse/jetty/server/RequestTest.java @@ -1207,7 +1207,7 @@ public class RequestTest @Test - public void testHashDOS() throws Exception + public void testHashDOSKeys() throws Exception { ((StdErrLog)Log.getLogger(HttpChannel.class)).setHideStacks(true); LOG.info("Expecting maxFormKeys limit and Closing HttpParser exceptions..."); @@ -1269,6 +1269,52 @@ public class RequestTest ((StdErrLog)Log.getLogger(HttpChannel.class)).setHideStacks(false); } } + + @Test + public void testHashDOSSize() throws Exception + { + ((StdErrLog)Log.getLogger(HttpChannel.class)).setHideStacks(true); + LOG.info("Expecting maxFormSize limit and too much data exceptions..."); + _server.setAttribute("org.eclipse.jetty.server.Request.maxFormContentSize",3396); + _server.setAttribute("org.eclipse.jetty.server.Request.maxFormKeys",1000); + + StringBuilder buf = new StringBuilder(4000000); + buf.append("a=b"); + // we will just create a lot of keys and make sure the limit is applied + for (int i=0;i<500;i++) + buf.append("&").append("K").append(i).append("=").append("x"); + buf.append("&c=d"); + + _handler._checker = new RequestTester() + { + @Override + public boolean check(HttpServletRequest request,HttpServletResponse response) + { + return "b".equals(request.getParameter("a")) && request.getParameter("c")==null; + } + }; + + String request="POST / HTTP/1.1\r\n"+ + "Host: whatever\r\n"+ + "Content-Type: "+MimeTypes.Type.FORM_ENCODED.asString()+"\r\n"+ + "Content-Length: "+buf.length()+"\r\n"+ + "Connection: close\r\n"+ + "\r\n"+ + buf; + + try + { + long start=System.currentTimeMillis(); + String response = _connector.getResponses(request); + assertTrue(response.contains("Form too large:")); + long now=System.currentTimeMillis(); + assertTrue((now-start)<5000); + } + finally + { + ((StdErrLog)Log.getLogger(HttpChannel.class)).setHideStacks(false); + } + } @Test(expected = UnsupportedEncodingException.class) public void testNotSupportedCharacterEncoding() throws UnsupportedEncodingException From 41029ca6f880ccb05d7464090f29710e339c449e Mon Sep 17 00:00:00 2001 From: Joakim Erdfelt Date: Thu, 22 Jan 2015 07:20:16 -0700 Subject: [PATCH 2/2] Breaking ant caching for jmx tests --- tests/test-jmx/jmx-webapp-it/pom.xml | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/tests/test-jmx/jmx-webapp-it/pom.xml b/tests/test-jmx/jmx-webapp-it/pom.xml index a27d6d32d5f..7429e49c7d9 100644 --- a/tests/test-jmx/jmx-webapp-it/pom.xml +++ b/tests/test-jmx/jmx-webapp-it/pom.xml @@ -123,8 +123,8 @@ - - + + Integration Test : Setup Jetty - - + + Integration Test : Starting Jetty ... @@ -143,8 +143,8 @@ - - + + @@ -162,8 +162,8 @@ - - + + Integration Test : Stop Jetty - - + +