Search in sources :

Example 1 with ResponseWrapper

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

the class TestPropertiesPlugin method testListPlatformBeansToo.

@Test
public void testListPlatformBeansToo() {
    HttpFullRequest req = Requests.createRequest(KnownHttpMethod.GET, "/@properties");
    // 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 login page
    response.assertStatusCode(KnownStatusCode.HTTP_200_OK);
    response.assertContains("<a href=`/@properties/bean/Webpieces+Router/CookieTranslator.class`>CookieTranslator.class</a>".replace("`", "\""));
}
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) Test(org.junit.Test) WebserverForTest(org.webpieces.plugins.fortesting.WebserverForTest) AbstractWebpiecesTest(org.webpieces.webserver.test.AbstractWebpiecesTest)

Example 2 with ResponseWrapper

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

the class TestSslSetup method testAlreadyLoggedInAndFirstTimeNoProperties.

@Test
public void testAlreadyLoggedInAndFirstTimeNoProperties() throws MalformedURLException {
    URI terms = URI.create("http://somerandom.com/place");
    URL website = new URL("http://website.com");
    mockStorage.addReadResponse(XFuture.completedFuture(new HashMap<>()));
    HttpFullRequest req = Requests.createRequest(KnownHttpMethod.GET, "/@sslcert");
    // 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"));
    mockAcmeClient.setRemoteInfo(XFuture.completedFuture(new AcmeInfo(terms, website)));
    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("You Must agree to the terms found at");
}
Also used : HttpFullResponse(org.webpieces.httpclient11.api.HttpFullResponse) HttpFullRequest(org.webpieces.httpclient11.api.HttpFullRequest) Header(org.webpieces.httpparser.api.common.Header) HashMap(java.util.HashMap) ResponseWrapper(org.webpieces.webserver.test.ResponseWrapper) URI(java.net.URI) URL(java.net.URL) AcmeInfo(org.webpieces.plugin.secure.sslcert.acme.AcmeInfo) WebserverForTest(org.webpieces.plugins.fortesting.WebserverForTest) AbstractWebpiecesTest(org.webpieces.webserver.test.AbstractWebpiecesTest) Test(org.junit.Test)

Example 3 with ResponseWrapper

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

the class TestSslSetup method testPostEmailNotLoggedInBecauseeNoCookie.

@Test
public void testPostEmailNotLoggedInBecauseeNoCookie() {
    HttpFullRequest req = Requests.createPostRequest("/@sslcert/postEmail", "email", "dean@gmail.com");
    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/@backend/login", 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) WebserverForTest(org.webpieces.plugins.fortesting.WebserverForTest) AbstractWebpiecesTest(org.webpieces.webserver.test.AbstractWebpiecesTest) Test(org.junit.Test)

Example 4 with ResponseWrapper

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

the class TestSslSetup method testAccessPageWillRedirectToLogin.

@Test
public void testAccessPageWillRedirectToLogin() {
    HttpFullRequest req = Requests.createRequest(KnownHttpMethod.GET, "/@sslcert");
    XFuture<HttpFullResponse> respFuture = https11Socket.send(req);
    ResponseWrapper response = ResponseExtract.waitResponseAndWrap(respFuture);
    // redirect to the login page in the backend plugin...
    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/@backend/login", 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) WebserverForTest(org.webpieces.plugins.fortesting.WebserverForTest) AbstractWebpiecesTest(org.webpieces.webserver.test.AbstractWebpiecesTest) Test(org.junit.Test)

Example 5 with ResponseWrapper

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

the class TestFullSslSetupWizard method postOrgAndPlaceOrderAndFinalizeOrder.

private MockProxyAuthorization postOrgAndPlaceOrderAndFinalizeOrder(String url) throws MalformedURLException {
    URL accountUrl = new URL("http://someurlfor.com/myexact/account/1234");
    mockAcmeClient.setOpenAccount(XFuture.completedFuture(accountUrl));
    List<ProxyAuthorization> proxyAuth = new ArrayList<>();
    MockProxyAuthorization mockProxyAuth = new MockProxyAuthorization("domain.com", Instant.now(), Status.PENDING, new URL("http://somelocation.asdf"), "sometokenforwebdisplay", "authcontent111");
    proxyAuth.add(mockProxyAuth);
    mockAcmeClient.setProxyOrder(XFuture.completedFuture(new ProxyOrder(null, proxyAuth)));
    mockAcmeClient.setCertAndSigningRequest(XFuture.completedFuture(new CertAndSigningRequest("fakecsr", new ArrayList<>())));
    HttpFullRequest req = Requests.createPostRequest(url, "organization", "DeanCo");
    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/maintainssl", headers.get(0).getValue());
    return mockProxyAuth;
}
Also used : ProxyOrder(org.webpieces.plugin.secure.sslcert.acme.ProxyOrder) ArrayList(java.util.ArrayList) ResponseWrapper(org.webpieces.webserver.test.ResponseWrapper) URL(java.net.URL) CertAndSigningRequest(org.webpieces.plugin.secure.sslcert.CertAndSigningRequest) HttpFullResponse(org.webpieces.httpclient11.api.HttpFullResponse) HttpFullRequest(org.webpieces.httpclient11.api.HttpFullRequest) Header(org.webpieces.httpparser.api.common.Header) ProxyAuthorization(org.webpieces.plugin.secure.sslcert.acme.ProxyAuthorization)

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