Search in sources :

Example 36 with HttpFullRequest

use of org.webpieces.httpclient11.api.HttpFullRequest in project webpieces by deanhiller.

the class TestGetCorsRouting method testCookie200Ok.

@Test
public void testCookie200Ok() {
    String cookieValue = "key1=value1;key2=value2";
    List<String> accessHeaders = List.of("Authorization", "asfsf");
    HttpFullRequest req = Requests.createCorsRequestCookie(CorsForTwoDomains.DOMAIN1, "/content", accessHeaders, KnownHttpMethod.PUT, cookieValue);
    XFuture<HttpFullResponse> respFuture = httpsSocket.send(req);
    ResponseWrapper response = ResponseExtract.waitResponseAndWrap(respFuture);
    response.assertStatusCode(KnownStatusCode.HTTP_200_OK);
}
Also used : HttpFullResponse(org.webpieces.httpclient11.api.HttpFullResponse) HttpFullRequest(org.webpieces.httpclient11.api.HttpFullRequest) ResponseWrapper(org.webpieces.webserver.test.ResponseWrapper) PrivateWebserverForTest(org.webpieces.webserver.PrivateWebserverForTest) Test(org.junit.Test) AbstractWebpiecesTest(org.webpieces.webserver.test.AbstractWebpiecesTest)

Example 37 with HttpFullRequest

use of org.webpieces.httpclient11.api.HttpFullRequest in project webpieces by deanhiller.

the class TestHttps method testReverseUrlLookupOnHttpPageForHttpsUrl.

@Test
public void testReverseUrlLookupOnHttpPageForHttpsUrl() {
    HttpFullRequest req = Requests.createRequest(KnownHttpMethod.GET, "/same");
    XFuture<HttpFullResponse> respFuture = http11Socket.send(req);
    ResponseWrapper response = ResponseExtract.waitResponseAndWrap(respFuture);
    response.assertStatusCode(KnownStatusCode.HTTP_200_OK);
    // since request came in on port 80, url should be port 443
    // notice the Https Route page is not shown
    response.assertContains("https://myhost.com:443");
}
Also used : HttpFullResponse(org.webpieces.httpclient11.api.HttpFullResponse) HttpFullRequest(org.webpieces.httpclient11.api.HttpFullRequest) ResponseWrapper(org.webpieces.webserver.test.ResponseWrapper) PrivateWebserverForTest(org.webpieces.webserver.PrivateWebserverForTest) Test(org.junit.Test) AbstractWebpiecesTest(org.webpieces.webserver.test.AbstractWebpiecesTest)

Example 38 with HttpFullRequest

use of org.webpieces.httpclient11.api.HttpFullRequest in project webpieces by deanhiller.

the class TestHttps method testSecureLoginNotFoundHttpsPage.

@Test
public void testSecureLoginNotFoundHttpsPage() {
    HttpFullRequest req = Requests.createRequest(KnownHttpMethod.GET, "/secure/notFoundPage");
    XFuture<HttpFullResponse> respFuture = https11Socket.send(req);
    ResponseWrapper response = ResponseExtract.waitResponseAndWrap(respFuture);
    // Page not exist
    response.assertStatusCode(KnownStatusCode.HTTP_404_NOTFOUND);
}
Also used : HttpFullResponse(org.webpieces.httpclient11.api.HttpFullResponse) HttpFullRequest(org.webpieces.httpclient11.api.HttpFullRequest) ResponseWrapper(org.webpieces.webserver.test.ResponseWrapper) PrivateWebserverForTest(org.webpieces.webserver.PrivateWebserverForTest) Test(org.junit.Test) AbstractWebpiecesTest(org.webpieces.webserver.test.AbstractWebpiecesTest)

Example 39 with HttpFullRequest

use of org.webpieces.httpclient11.api.HttpFullRequest in project webpieces by deanhiller.

the class TestHttps method testSecureLoginHasHttpsPage.

@Test
public void testSecureLoginHasHttpsPage() {
    HttpFullRequest req = Requests.createRequest(KnownHttpMethod.GET, "/secure/internal");
    XFuture<HttpFullResponse> respFuture = https11Socket.send(req);
    ResponseWrapper response = ResponseExtract.waitResponseAndWrap(respFuture);
    // before we can show you the page, you need to be logged in, redirect to login page...
    response.assertStatusCode(KnownStatusCode.HTTP_303_SEEOTHER);
}
Also used : HttpFullResponse(org.webpieces.httpclient11.api.HttpFullResponse) HttpFullRequest(org.webpieces.httpclient11.api.HttpFullRequest) ResponseWrapper(org.webpieces.webserver.test.ResponseWrapper) PrivateWebserverForTest(org.webpieces.webserver.PrivateWebserverForTest) Test(org.junit.Test) AbstractWebpiecesTest(org.webpieces.webserver.test.AbstractWebpiecesTest)

Example 40 with HttpFullRequest

use of org.webpieces.httpclient11.api.HttpFullRequest in project webpieces by deanhiller.

the class TestHttps method testSameRouteHttpAndHttpsWrongOrder.

@Test
public void testSameRouteHttpAndHttpsWrongOrder() {
    HttpFullRequest req = Requests.createRequest(KnownHttpMethod.GET, "/same");
    XFuture<HttpFullResponse> respFuture1 = https11Socket.send(req);
    ResponseWrapper response = ResponseExtract.waitResponseAndWrap(respFuture1);
    response.assertStatusCode(KnownStatusCode.HTTP_200_OK);
    // notice the Https Route page is not shown
    response.assertContains("Http Route");
    XFuture<HttpFullResponse> respFuture = http11Socket.send(req);
    response = ResponseExtract.waitResponseAndWrap(respFuture);
    response.assertStatusCode(KnownStatusCode.HTTP_200_OK);
    // notice the Https Route page is not shown
    response.assertContains("Http Route");
}
Also used : HttpFullResponse(org.webpieces.httpclient11.api.HttpFullResponse) HttpFullRequest(org.webpieces.httpclient11.api.HttpFullRequest) ResponseWrapper(org.webpieces.webserver.test.ResponseWrapper) PrivateWebserverForTest(org.webpieces.webserver.PrivateWebserverForTest) Test(org.junit.Test) AbstractWebpiecesTest(org.webpieces.webserver.test.AbstractWebpiecesTest)

Aggregations

HttpFullRequest (org.webpieces.httpclient11.api.HttpFullRequest)222 HttpFullResponse (org.webpieces.httpclient11.api.HttpFullResponse)205 ResponseWrapper (org.webpieces.webserver.test.ResponseWrapper)204 Test (org.junit.Test)194 AbstractWebpiecesTest (org.webpieces.webserver.test.AbstractWebpiecesTest)193 PrivateWebserverForTest (org.webpieces.webserver.PrivateWebserverForTest)180 Header (org.webpieces.httpparser.api.common.Header)50 XFuture (org.webpieces.util.futures.XFuture)13 HttpRequest (org.webpieces.httpparser.api.dto.HttpRequest)12 Http2Header (com.webpieces.http2.api.dto.lowlevel.lib.Http2Header)9 HttpRequestLine (org.webpieces.httpparser.api.dto.HttpRequestLine)9 HttpUri (org.webpieces.httpparser.api.dto.HttpUri)9 WebserverForTest (org.webpieces.plugins.fortesting.WebserverForTest)8 DataWrapper (org.webpieces.data.api.DataWrapper)6 UserDto (org.webpieces.webserver.basic.app.biz.UserDto)4 URL (java.net.URL)3 UserTestDbo (org.webpieces.plugins.hibernate.app.dbo.UserTestDbo)3 URI (java.net.URI)2 ByteBuffer (java.nio.ByteBuffer)2 NotFoundException (org.webpieces.http.exception.NotFoundException)2