Search in sources :

Example 1 with HttpFullResponse

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

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

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

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

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

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