Search in sources :

Example 36 with HttpFullResponse

use of org.webpieces.httpclient11.api.HttpFullResponse 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 37 with HttpFullResponse

use of org.webpieces.httpclient11.api.HttpFullResponse 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 38 with HttpFullResponse

use of org.webpieces.httpclient11.api.HttpFullResponse 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 39 with HttpFullResponse

use of org.webpieces.httpclient11.api.HttpFullResponse 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)

Example 40 with HttpFullResponse

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

the class TestHttps method testUseHttpButGoThroughLoginFilter.

@Test
public void testUseHttpButGoThroughLoginFilter() {
    HttpFullRequest req = Requests.createRequest(KnownHttpMethod.GET, "/secure/randomPage");
    XFuture<HttpFullResponse> respFuture = http11Socket.send(req);
    ResponseWrapper response = ResponseExtract.waitResponseAndWrap(respFuture);
    // Even though the page exists....if accessed over http, it does 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)

Aggregations

HttpFullResponse (org.webpieces.httpclient11.api.HttpFullResponse)208 HttpFullRequest (org.webpieces.httpclient11.api.HttpFullRequest)204 ResponseWrapper (org.webpieces.webserver.test.ResponseWrapper)200 Test (org.junit.Test)192 AbstractWebpiecesTest (org.webpieces.webserver.test.AbstractWebpiecesTest)192 PrivateWebserverForTest (org.webpieces.webserver.PrivateWebserverForTest)178 Header (org.webpieces.httpparser.api.common.Header)39 XFuture (org.webpieces.util.futures.XFuture)12 WebserverForTest (org.webpieces.plugins.fortesting.WebserverForTest)8 URL (java.net.URL)3 UserTestDbo (org.webpieces.plugins.hibernate.app.dbo.UserTestDbo)3 UserDto (org.webpieces.webserver.basic.app.biz.UserDto)3 URI (java.net.URI)2 DataWrapper (org.webpieces.data.api.DataWrapper)2 NotFoundException (org.webpieces.http.exception.NotFoundException)2 HttpData (org.webpieces.httpparser.api.dto.HttpData)2 HttpResponse (org.webpieces.httpparser.api.dto.HttpResponse)2 AcmeInfo (org.webpieces.plugin.secure.sslcert.acme.AcmeInfo)2 SearchRequest (org.webpieces.webserver.json.app.SearchRequest)2 FetchValueResponse (webpiecesxxxxxpackage.service.FetchValueResponse)2