use of org.webpieces.webserver.test.FullResponse in project webpieces by deanhiller.
the class TestHttps method simulateLogin.
private Header simulateLogin() {
HttpRequest req1 = Requests.createRequest(KnownHttpMethod.POST, "/postLogin");
httpsSocket.send(req1);
FullResponse response1 = ResponseExtract.assertSingleResponse(httpsSocket);
Header header = response1.getResponse().getHeaderLookupStruct().getHeader(KnownHeaderName.SET_COOKIE);
String value = header.getValue();
value = value.replace("; path=/; HttpOnly", "");
Header cookie = new Header(KnownHeaderName.COOKIE, value);
return cookie;
}
use of org.webpieces.webserver.test.FullResponse in project webpieces by deanhiller.
the class TestScopes method runInvalidPost.
private FullResponse runInvalidPost() {
HttpDummyRequest req = Requests.createPostRequest("/user/post", //invalid first name
"user.firstName", //invalid first name
"D", "user.lastName", "Hiller", "user.fullName", "Dean Hiller", "user.address.zipCode", "555", "user.address.street", "Coolness Dr.");
http11Socket.send(req);
FullResponse response = ResponseExtract.assertSingleResponse(http11Socket);
response.assertStatusCode(KnownStatusCode.HTTP_303_SEEOTHER);
return response;
}
use of org.webpieces.webserver.test.FullResponse in project webpieces by deanhiller.
the class TestScopes method testGetStaticFileDoesNotClearFlashMessage.
@Test
public void testGetStaticFileDoesNotClearFlashMessage() {
HttpRequest req = Requests.createRequest(KnownHttpMethod.GET, "/flashmessage");
http11Socket.send(req);
FullResponse response = ResponseExtract.assertSingleResponse(http11Socket);
response.assertStatusCode(KnownStatusCode.HTTP_200_OK);
Header header = response.createCookieRequestHeader();
HttpRequest req2 = Requests.createRequest(KnownHttpMethod.GET, "/public/fonts.css");
req2.addHeader(header);
http11Socket.send(req2);
FullResponse response2 = ResponseExtract.assertSingleResponse(http11Socket);
response2.assertStatusCode(KnownStatusCode.HTTP_200_OK);
Header cookie = response2.getResponse().getHeaderLookupStruct().getHeader(KnownHeaderName.SET_COOKIE);
Assert.assertNull("static routes should not be clearing cookies or things go south", cookie);
}
use of org.webpieces.webserver.test.FullResponse in project webpieces by deanhiller.
the class TestDevSynchronousErrors method testWebAppHasBugRenders500Route.
/**
* This tests bug in your webapp "/another" route, you could also test you have a bug in that route AND a bug in your internal
* server route as well!!!
*/
@Test
public void testWebAppHasBugRenders500Route() {
mockNotFoundLib.throwRuntime();
HttpRequest req = Requests.createRequest(KnownHttpMethod.GET, "/");
http11Socket.send(req);
FullResponse response = ResponseExtract.assertSingleResponse(http11Socket);
response.assertStatusCode(KnownStatusCode.HTTP_500_INTERNAL_SVR_ERROR);
response.assertContains("There was a bug in our software...sorry about that");
}
use of org.webpieces.webserver.test.FullResponse in project webpieces by deanhiller.
the class TestDevSynchronousErrors method testWebappThrowsNotFound.
@Test
public void testWebappThrowsNotFound() {
HttpRequest req = Requests.createRequest(KnownHttpMethod.GET, "/throwNotFound");
http11Socket.send(req);
FullResponse response = ResponseExtract.assertSingleResponse(http11Socket);
response.assertStatusCode(KnownStatusCode.HTTP_404_NOTFOUND);
response.assertContains("Your app's webpage was not found");
}
Aggregations