Search in sources :

Example 46 with HttpRequest

use of org.webpieces.httpparser.api.dto.HttpRequest in project webpieces by deanhiller.

the class TestDevSynchronousErrors method testWebAppHasBugAndRender500HasBug.

@Test
public void testWebAppHasBugAndRender500HasBug() {
    mockNotFoundLib.throwRuntime();
    mockInternalSvrErrorLib.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("The webpieces platform saved them");
}
Also used : HttpRequest(org.webpieces.httpparser.api.dto.HttpRequest) FullResponse(org.webpieces.webserver.test.FullResponse) AbstractWebpiecesTest(org.webpieces.webserver.test.AbstractWebpiecesTest) PlatformOverridesForTest(org.webpieces.webserver.test.PlatformOverridesForTest) Test(org.junit.Test) WebserverForTest(org.webpieces.webserver.WebserverForTest)

Example 47 with HttpRequest

use of org.webpieces.httpparser.api.dto.HttpRequest in project webpieces by deanhiller.

the class TestDevSynchronousErrors method testNotFoundFromMismatchArgType.

@Test
public void testNotFoundFromMismatchArgType() {
    //because 'notAnInt' is not convertable to integer, this result in NotFound rather than 500 as truly a route with
    //no int doesn't really exist so it's a NotFound
    HttpRequest req = Requests.createRequest(KnownHttpMethod.GET, "/redirectint/notAnInt");
    http11Socket.send(req);
    FullResponse response = ResponseExtract.assertSingleResponse(http11Socket);
    response.assertStatusCode(KnownStatusCode.HTTP_404_NOTFOUND);
    response.assertContains("Your app's webpage was not found");
}
Also used : HttpRequest(org.webpieces.httpparser.api.dto.HttpRequest) FullResponse(org.webpieces.webserver.test.FullResponse) AbstractWebpiecesTest(org.webpieces.webserver.test.AbstractWebpiecesTest) PlatformOverridesForTest(org.webpieces.webserver.test.PlatformOverridesForTest) Test(org.junit.Test) WebserverForTest(org.webpieces.webserver.WebserverForTest)

Example 48 with HttpRequest

use of org.webpieces.httpparser.api.dto.HttpRequest in project webpieces by deanhiller.

the class TestHttps method testReverseUrlLookupOnHttpPageForHttpsUrl.

@Test
public void testReverseUrlLookupOnHttpPageForHttpsUrl() {
    HttpRequest req = Requests.createRequest(KnownHttpMethod.GET, "/same");
    httpSocket.send(req);
    FullResponse response = ResponseExtract.assertSingleResponse(httpSocket);
    response.assertStatusCode(KnownStatusCode.HTTP_200_OK);
    //notice the Https Route page is not shown	
    response.assertContains("https://myhost.com:8443");
}
Also used : HttpRequest(org.webpieces.httpparser.api.dto.HttpRequest) FullResponse(org.webpieces.webserver.test.FullResponse) Test(org.junit.Test) AbstractWebpiecesTest(org.webpieces.webserver.test.AbstractWebpiecesTest) WebserverForTest(org.webpieces.webserver.WebserverForTest)

Example 49 with HttpRequest

use of org.webpieces.httpparser.api.dto.HttpRequest 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;
}
Also used : HttpRequest(org.webpieces.httpparser.api.dto.HttpRequest) FullResponse(org.webpieces.webserver.test.FullResponse) Header(org.webpieces.httpparser.api.common.Header)

Example 50 with HttpRequest

use of org.webpieces.httpparser.api.dto.HttpRequest 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);
}
Also used : HttpRequest(org.webpieces.httpparser.api.dto.HttpRequest) FullResponse(org.webpieces.webserver.test.FullResponse) Header(org.webpieces.httpparser.api.common.Header) Test(org.junit.Test) AbstractWebpiecesTest(org.webpieces.webserver.test.AbstractWebpiecesTest) WebserverForTest(org.webpieces.webserver.WebserverForTest)

Aggregations

HttpRequest (org.webpieces.httpparser.api.dto.HttpRequest)157 Test (org.junit.Test)136 AbstractWebpiecesTest (org.webpieces.webserver.test.AbstractWebpiecesTest)120 FullResponse (org.webpieces.webserver.test.FullResponse)120 WebserverForTest (org.webpieces.webserver.WebserverForTest)114 Header (org.webpieces.httpparser.api.common.Header)33 DataWrapper (org.webpieces.data.api.DataWrapper)17 PlatformOverridesForTest (org.webpieces.webserver.test.PlatformOverridesForTest)15 HttpData (org.webpieces.httpparser.api.dto.HttpData)13 HttpRequestLine (org.webpieces.httpparser.api.dto.HttpRequestLine)13 HttpUri (org.webpieces.httpparser.api.dto.HttpUri)13 CompletableFuture (java.util.concurrent.CompletableFuture)11 PassedIn (org.webpieces.httpfrontend2.api.mock2.MockHttp2RequestListener.PassedIn)8 HttpPayload (org.webpieces.httpparser.api.dto.HttpPayload)8 HttpResponse (org.webpieces.httpparser.api.dto.HttpResponse)8 Http2Response (com.webpieces.hpack.api.dto.Http2Response)6 HttpDummyRequest (org.webpieces.webserver.test.HttpDummyRequest)6 DataFrame (com.webpieces.http2parser.api.dto.DataFrame)4 StreamWriter (com.webpieces.http2engine.api.StreamWriter)3 Http2Header (com.webpieces.http2parser.api.dto.lib.Http2Header)3