Skip to content

Commit

Permalink
Add automated test for JENKINS-73285 (#393)
Browse files Browse the repository at this point in the history
  • Loading branch information
basil authored Jun 25, 2024
1 parent d66e39d commit 0bedfa0
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/test/java/winstone/FormSubmissionTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,24 @@ public void largeForm() throws Exception {
response.body());
}
}

@Issue("JENKINS-73285")
@Test
public void duplicateKeys() throws Exception {
Map<String, String> args = new HashMap<>();
args.put("warfile", "target/test-classes/test.war");
args.put("prefix", "/");
args.put("httpPort", "0");
args.put("httpListenAddress", "127.0.0.2");
winstone = new Launcher(args);
int port = ((ServerConnector) winstone.server.getConnectors()[0]).getLocalPort();
String queryString = "foo=bar" + "&foo=bar".repeat(1000);
HttpRequest request = HttpRequest.newBuilder(new URI("http://127.0.0.2:" + port + "/AcceptFormServlet"))
.header("Content-Type", "application/x-www-form-urlencoded")
.POST(HttpRequest.BodyPublishers.ofString(queryString))
.build();
HttpResponse<String> response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
assertEquals(HttpURLConnection.HTTP_OK, response.statusCode());
assertEquals("received " + queryString.length() + " bytes", response.body());
}
}

0 comments on commit 0bedfa0

Please sign in to comment.