Search in sources :

Example 61 with HttpRequest

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

the class TestDevRefreshPageWithNoRestarting method testNotFoundDisplaysWithIframeANDSpecialUrl.

@Test
public void testNotFoundDisplaysWithIframeANDSpecialUrl() {
    HttpRequest req = Requests.createRequest(KnownHttpMethod.GET, "/notFound");
    http11Socket.send(req);
    FullResponse response = ResponseExtract.assertSingleResponse(http11Socket);
    response.assertStatusCode(KnownStatusCode.HTTP_404_NOTFOUND);
    //platform should convert request into a development not found page which has an iframe
    //of the original page with a query param to tell platform to display original 
    //page requested 
    response.assertContains("<iframe src=\"/notFound?webpiecesShowPage=true");
}
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 62 with HttpRequest

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

the class TestDevRefreshPageWithNoRestarting method testNotFoundFilterModified.

@Test
public void testNotFoundFilterModified() throws IOException {
    HttpRequest req = Requests.createRequest(KnownHttpMethod.GET, "/enableFilter?webpiecesShowPage=true");
    http11Socket.send(req);
    verify303("http://myhost.com/home");
    simulateDeveloperMakesChanges("src/test/devServerTest/notFound");
    http11Socket.send(req);
    verify303("http://myhost.com/filter");
}
Also used : HttpRequest(org.webpieces.httpparser.api.dto.HttpRequest) AbstractWebpiecesTest(org.webpieces.webserver.test.AbstractWebpiecesTest) PlatformOverridesForTest(org.webpieces.webserver.test.PlatformOverridesForTest) Test(org.junit.Test) WebserverForTest(org.webpieces.webserver.WebserverForTest)

Example 63 with HttpRequest

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

the class TestHttps method testSameRouteHttpAndHttpsCorrectOrder.

@Test
public void testSameRouteHttpAndHttpsCorrectOrder() {
    HttpRequest req = Requests.createRequest(KnownHttpMethod.GET, "/same2");
    httpsSocket.send(req);
    FullResponse response = ResponseExtract.assertSingleResponse(httpsSocket);
    response.assertStatusCode(KnownStatusCode.HTTP_200_OK);
    response.assertContains("Https Route");
    httpSocket.send(req);
    response = ResponseExtract.assertSingleResponse(httpSocket);
    response.assertStatusCode(KnownStatusCode.HTTP_200_OK);
    response.assertContains("Http Route");
}
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 64 with HttpRequest

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

the class TestHttps method testSecureAndLoggedInAlready.

@Test
public void testSecureAndLoggedInAlready() {
    Header cookie = simulateLogin();
    HttpRequest req = Requests.createRequest(KnownHttpMethod.GET, "/secure/internal");
    req.addHeader(cookie);
    httpsSocket.send(req);
    FullResponse response = ResponseExtract.assertSingleResponse(httpsSocket);
    //before we can show you the page, you need to be logged in, redirect to login page...
    response.assertStatusCode(KnownStatusCode.HTTP_200_OK);
    response.assertContains("This is some home page");
}
Also used : HttpRequest(org.webpieces.httpparser.api.dto.HttpRequest) Header(org.webpieces.httpparser.api.common.Header) FullResponse(org.webpieces.webserver.test.FullResponse) Test(org.junit.Test) AbstractWebpiecesTest(org.webpieces.webserver.test.AbstractWebpiecesTest) WebserverForTest(org.webpieces.webserver.WebserverForTest)

Example 65 with HttpRequest

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

the class TestHttps method testSecureLoginNotFoundHttpsPage.

@Test
public void testSecureLoginNotFoundHttpsPage() {
    HttpRequest req = Requests.createRequest(KnownHttpMethod.GET, "/secure/notFoundPage");
    httpsSocket.send(req);
    FullResponse response = ResponseExtract.assertSingleResponse(httpsSocket);
    //Even though the page doesn't exist, we redirect all /secure/* to login page
    response.assertStatusCode(KnownStatusCode.HTTP_303_SEEOTHER);
}
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)

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