diff options
author | Bjørn Christian Seime <bjorncs@vespa.ai> | 2024-03-14 13:29:11 +0100 |
---|---|---|
committer | Bjørn Christian Seime <bjorncs@vespa.ai> | 2024-03-14 13:29:11 +0100 |
commit | b0e0e63990a1a2e3361fa182d0fac3b94e2d4257 (patch) | |
tree | ab8bb3ef390ca4aaffa48552f33337d6c763b1a1 /container-core/src/test/java/com/yahoo/jdisc/http/server | |
parent | 6c76d7dfcf6df3e1f92034d114b55425071faef8 (diff) |
Fail with 400 for bad `application/x-www-form-urlencoded` requests
Diffstat (limited to 'container-core/src/test/java/com/yahoo/jdisc/http/server')
-rw-r--r-- | container-core/src/test/java/com/yahoo/jdisc/http/server/jetty/HttpServerTest.java | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/container-core/src/test/java/com/yahoo/jdisc/http/server/jetty/HttpServerTest.java b/container-core/src/test/java/com/yahoo/jdisc/http/server/jetty/HttpServerTest.java index 32375be2a68..9c17ce7d0da 100644 --- a/container-core/src/test/java/com/yahoo/jdisc/http/server/jetty/HttpServerTest.java +++ b/container-core/src/test/java/com/yahoo/jdisc/http/server/jetty/HttpServerTest.java @@ -288,6 +288,19 @@ public class HttpServerTest { } @Test + void requireThatFormPostWithInvalidDataFailsWith400() throws Exception { + final JettyTestDriver driver = newDriverWithFormPostContentRemoved(new ParameterPrinterRequestHandler(), true); + final ResponseValidator response = + driver.client().newPost("/status.html") + .addHeader(CONTENT_TYPE, APPLICATION_X_WWW_FORM_URLENCODED) + .setContent("%!Foo=bar") + .execute(); + response.expectStatusCode(is(BAD_REQUEST)) + .expectContent(containsString("Failed to parse form parameters")); + assertTrue(driver.close()); + } + + @Test void requireThatFormPostWithCharsetSpecifiedWorks() throws Exception { final JettyTestDriver driver = JettyTestDriver.newInstance(new ParameterPrinterRequestHandler()); final String requestContent = generateContent('a', 30); |