use of org.webpieces.httpclient11.api.HttpFullRequest 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("`", "\""));
}
use of org.webpieces.httpclient11.api.HttpFullRequest 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");
}
use of org.webpieces.httpclient11.api.HttpFullRequest 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());
}
use of org.webpieces.httpclient11.api.HttpFullRequest 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());
}
use of org.webpieces.httpclient11.api.HttpFullRequest 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;
}
Aggregations