This commit is contained in:
Greg Wilkins 2017-10-17 14:04:53 +11:00
parent 080d0250fc
commit 52baec434b
1 changed files with 37 additions and 0 deletions

View File

@ -100,6 +100,7 @@ public class RequestTest
_server.setHandler(_handler); _server.setHandler(_handler);
ErrorHandler errors = new ErrorHandler(); ErrorHandler errors = new ErrorHandler();
errors.setServer(_server);
errors.setShowStacks(true); errors.setShowStacks(true);
_server.addBean(errors); _server.addBean(errors);
_server.start(); _server.start();
@ -1383,6 +1384,42 @@ public class RequestTest
} }
@Test
public void testBadCookies() throws Exception
{
final ArrayList<Cookie> cookies = new ArrayList<>();
_handler._checker = new RequestTester()
{
@Override
public boolean check(HttpServletRequest request,HttpServletResponse response) throws IOException
{
javax.servlet.http.Cookie[] ca = request.getCookies();
if (ca!=null)
cookies.addAll(Arrays.asList(ca));
response.getOutputStream().println("Hello World");
return true;
}
};
String response;
cookies.clear();
response=_connector.getResponses(
"GET / HTTP/1.1\n"+
"Host: whatever\n"+
"Cookie: path=value\n" +
"Cookie: name=value\n" +
"Connection: close\n"+
"\n"
);
assertTrue(response.startsWith("HTTP/1.1 200 OK"));
assertEquals(1,cookies.size());
assertEquals("name", cookies.get(0).getName());
assertEquals("value", cookies.get(0).getValue());
}
@Ignore("No longer relevant") @Ignore("No longer relevant")
@Test @Test
public void testCookieLeak() throws Exception public void testCookieLeak() throws Exception