Search in sources :

Example 6 with ResponseWrapper

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

the class TestFullSslSetupWizard method verifyTokenPageSetup.

private void verifyTokenPageSetup(MockProxyAuthorization proxyAuth) {
    HttpFullRequest req = Requests.createRequest(KnownHttpMethod.GET, "/.well-known/acme-challenge/" + proxyAuth.getToken());
    XFuture<HttpFullResponse> respFuture = https11Socket.send(req);
    ResponseWrapper response = ResponseExtract.waitResponseAndWrap(respFuture);
    response.assertStatusCode(KnownStatusCode.HTTP_200_OK);
    Assert.assertEquals(proxyAuth.getAuthContent(), response.getBodyAsString());
    response.assertContentType("text/plain");
    HttpFullRequest req2 = Requests.createRequest(KnownHttpMethod.GET, "/.well-known/acme-challenge/notexisttoken");
    XFuture<HttpFullResponse> respFuture2 = https11Socket.send(req2);
    ResponseWrapper response2 = ResponseExtract.waitResponseAndWrap(respFuture2);
    String url = response2.getRedirectUrl();
    response2.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)

Example 7 with ResponseWrapper

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

the class TestFullSslSetupWizard method postFirstPageAndEmail.

private void postFirstPageAndEmail(String url) {
    HttpFullRequest req = Requests.createPostRequest(url, "email", "dean@gmail.com");
    req.addHeader(new Header(KnownHeaderName.COOKIE, "webSession=1-xjrs6SeNeSxmJQtaTwM8gDorNiQ=:backendUser=admin"));
    XFuture<HttpFullResponse> respFuture = https11Socket.send(req);
    ResponseWrapper response = ResponseExtract.waitResponseAndWrap(respFuture);
    response.assertStatusCode(KnownStatusCode.HTTP_303_SEEOTHER);
    List<Header> headers = response.getResponse().getHeaderLookupStruct().getHeaders(KnownHeaderName.LOCATION);
    Assert.assertEquals(1, headers.size());
    Assert.assertEquals("https://myhost.com/@sslcert/step2", headers.get(0).getValue());
}
Also used : HttpFullResponse(org.webpieces.httpclient11.api.HttpFullResponse) HttpFullRequest(org.webpieces.httpclient11.api.HttpFullRequest) Header(org.webpieces.httpparser.api.common.Header) ResponseWrapper(org.webpieces.webserver.test.ResponseWrapper)

Example 8 with ResponseWrapper

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

the class TestFullSslSetupWizard method renderStep2AskingForOrg.

private void renderStep2AskingForOrg(String url) {
    HttpFullRequest req = Requests.createRequest(KnownHttpMethod.GET, url);
    // response from logging in taken from TestLogin in backend plugin test suite
    // set-cookie: webSession=1-xjrs6SeNeSxmJQtaTwM8gDorNiQ=:backendUser=admin; path=/; HttpOnly
    req.addHeader(new Header(KnownHeaderName.COOKIE, "webSession=1-xjrs6SeNeSxmJQtaTwM8gDorNiQ=:backendUser=admin"));
    XFuture<HttpFullResponse> respFuture = https11Socket.send(req);
    ResponseWrapper response = ResponseExtract.waitResponseAndWrap(respFuture);
    // redirect to the login page in the backend plugin...
    response.assertStatusCode(KnownStatusCode.HTTP_200_OK);
    response.assertContains("Organization");
}
Also used : HttpFullResponse(org.webpieces.httpclient11.api.HttpFullResponse) HttpFullRequest(org.webpieces.httpclient11.api.HttpFullRequest) Header(org.webpieces.httpparser.api.common.Header) ResponseWrapper(org.webpieces.webserver.test.ResponseWrapper)

Example 9 with ResponseWrapper

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

the class TestDomainMatching method testStaticFileFromDomain2NotFoundInDomain1.

@Test
public void testStaticFileFromDomain2NotFoundInDomain1() {
    HttpFullRequest req = Requests.createGetRequest("mydomain.com", "/public2/myfile");
    XFuture<HttpFullResponse> respFuture = httpsSocket.send(req);
    ResponseWrapper response = ResponseExtract.waitResponseAndWrap(respFuture);
    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 10 with ResponseWrapper

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

the class TestDomainMatching method testStaticDirFromDomain2NotFoundInDomain1.

@Test
public void testStaticDirFromDomain2NotFoundInDomain1() {
    HttpFullRequest req = Requests.createGetRequest("mydomain.com", "/public2/asyncMeta.txt");
    XFuture<HttpFullResponse> respFuture = httpsSocket.send(req);
    ResponseWrapper response = ResponseExtract.waitResponseAndWrap(respFuture);
    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

ResponseWrapper (org.webpieces.webserver.test.ResponseWrapper)209 HttpFullRequest (org.webpieces.httpclient11.api.HttpFullRequest)204 HttpFullResponse (org.webpieces.httpclient11.api.HttpFullResponse)200 Test (org.junit.Test)189 AbstractWebpiecesTest (org.webpieces.webserver.test.AbstractWebpiecesTest)189 PrivateWebserverForTest (org.webpieces.webserver.PrivateWebserverForTest)174 Header (org.webpieces.httpparser.api.common.Header)39 XFuture (org.webpieces.util.futures.XFuture)11 WebserverForTest (org.webpieces.plugins.fortesting.WebserverForTest)8 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 DataWrapper (org.webpieces.data.api.DataWrapper)2 NotFoundException (org.webpieces.http.exception.NotFoundException)2 AcmeInfo (org.webpieces.plugin.secure.sslcert.acme.AcmeInfo)2 SearchRequest (org.webpieces.webserver.json.app.SearchRequest)2 FetchValueResponse (webpiecesxxxxxpackage.service.FetchValueResponse)2 Counter (io.micrometer.core.instrument.Counter)1 RequiredSearch (io.micrometer.core.instrument.search.RequiredSearch)1