Search in sources :

Example 61 with FullResponse

use of org.webpieces.webserver.test.FullResponse 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 62 with FullResponse

use of org.webpieces.webserver.test.FullResponse 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)

Example 63 with FullResponse

use of org.webpieces.webserver.test.FullResponse in project webpieces by deanhiller.

the class TestHttps method testSameRouteHttpAndHttpsWrongOrder.

@Test
public void testSameRouteHttpAndHttpsWrongOrder() {
    HttpRequest req = Requests.createRequest(KnownHttpMethod.GET, "/same");
    httpsSocket.send(req);
    FullResponse response = ResponseExtract.assertSingleResponse(httpsSocket);
    response.assertStatusCode(KnownStatusCode.HTTP_200_OK);
    //notice the Https Route page is not shown		
    response.assertContains("Http Route");
    httpsSocket.clear();
    httpSocket.send(req);
    response = ResponseExtract.assertSingleResponse(httpSocket);
    response.assertStatusCode(KnownStatusCode.HTTP_200_OK);
    //notice the Https Route page is not shown	
    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 FullResponse

use of org.webpieces.webserver.test.FullResponse in project webpieces by deanhiller.

the class TestHttps method testSecureLoginHasHttpsPage.

@Test
public void testSecureLoginHasHttpsPage() {
    HttpRequest req = Requests.createRequest(KnownHttpMethod.GET, "/secure/internal");
    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_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)

Example 65 with FullResponse

use of org.webpieces.webserver.test.FullResponse in project webpieces by deanhiller.

the class TestHttps method testUseHttpButGoThroughLoginFilter.

@Test
public void testUseHttpButGoThroughLoginFilter() {
    HttpRequest req = Requests.createRequest(KnownHttpMethod.GET, "/secure/randomPage");
    httpSocket.send(req);
    FullResponse response = ResponseExtract.assertSingleResponse(httpSocket);
    //Even though the page exists....if accessed over http, it does not exist...
    response.assertStatusCode(KnownStatusCode.HTTP_404_NOTFOUND);
}
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

FullResponse (org.webpieces.webserver.test.FullResponse)154 Test (org.junit.Test)142 AbstractWebpiecesTest (org.webpieces.webserver.test.AbstractWebpiecesTest)142 WebserverForTest (org.webpieces.webserver.WebserverForTest)136 HttpRequest (org.webpieces.httpparser.api.dto.HttpRequest)120 HttpDummyRequest (org.webpieces.webserver.test.HttpDummyRequest)32 Header (org.webpieces.httpparser.api.common.Header)16 CompletableFuture (java.util.concurrent.CompletableFuture)11 PlatformOverridesForTest (org.webpieces.webserver.test.PlatformOverridesForTest)9 UserDto (org.webpieces.webserver.basic.app.biz.UserDto)4 UserTestDbo (org.webpieces.plugins.hibernate.app.dbo.UserTestDbo)3 NotFoundException (org.webpieces.router.api.exceptions.NotFoundException)2 ByteBuffer (java.nio.ByteBuffer)1 BufferCreationPool (org.webpieces.data.api.BufferCreationPool)1 DataWrapper (org.webpieces.data.api.DataWrapper)1 DataWrapperGenerator (org.webpieces.data.api.DataWrapperGenerator)1 HttpParser (org.webpieces.httpparser.api.HttpParser)1 MarshalState (org.webpieces.httpparser.api.MarshalState)1