use of org.webpieces.httpclient11.api.HttpFullResponse in project webpieces by deanhiller.
the class TestGetCorsRouting method testDomainInvalidResultIn403.
@Test
public void testDomainInvalidResultIn403() {
List<String> accessHeaders = List.of("Authorization", "Content-Type");
HttpFullRequest req = Requests.createCorsRequest("http://notallowed.domain.com", "/content", accessHeaders, KnownHttpMethod.PUT);
XFuture<HttpFullResponse> respFuture = httpsSocket.send(req);
ResponseWrapper response = ResponseExtract.waitResponseAndWrap(respFuture);
response.assertStatusCode(KnownStatusCode.HTTP_403_FORBIDDEN);
}
use of org.webpieces.httpclient11.api.HttpFullResponse in project webpieces by deanhiller.
the class TestGetCorsRouting method testOptionsDomain1.
@Test
public void testOptionsDomain1() {
List<String> accessHeaders = List.of("Authorization", "asfsf");
HttpFullRequest req = Requests.createCorsRequest(CorsForTwoDomains.DOMAIN1, "/content", accessHeaders, KnownHttpMethod.PUT);
XFuture<HttpFullResponse> respFuture = httpsSocket.send(req);
ResponseWrapper response = ResponseExtract.waitResponseAndWrap(respFuture);
response.assertStatusCode(KnownStatusCode.HTTP_200_OK);
Header allow = response.getResponse().getHeaderLookupStruct().getHeader("Allow");
// do not expose methods to a CORS request
Assert.assertNull(allow);
Header respDomain = response.getResponse().getHeaderLookupStruct().getHeader(KnownHeaderName.ACCESS_CONTROL_ALLOW_ORIGIN);
Assert.assertEquals(CorsForTwoDomains.DOMAIN1, respDomain.getValue());
// must tell client since there are two domains, the respond of Origin header may vary(ie. don't cache it)
Header vary = response.getResponse().getHeaderLookupStruct().getHeader(KnownHeaderName.VARY);
Assert.assertNull(vary);
}
use of org.webpieces.httpclient11.api.HttpFullResponse in project webpieces by deanhiller.
the class TestGetCorsRouting method testPostNotInCorsMethodsWithPostWithNotCORSRequestAndOriginExists.
@Test
public void testPostNotInCorsMethodsWithPostWithNotCORSRequestAndOriginExists() {
List<String> accessHeaders = List.of("Authorization");
HttpFullRequest req = Requests.createNotCorsRequest("/content", accessHeaders, KnownHttpMethod.POST);
XFuture<HttpFullResponse> respFuture = httpsSocket.send(req);
ResponseWrapper response = ResponseExtract.waitResponseAndWrap(respFuture);
response.assertStatusCode(KnownStatusCode.HTTP_200_OK);
}
use of org.webpieces.httpclient11.api.HttpFullResponse in project webpieces by deanhiller.
the class TestGetCorsRouting method testNoMatchMethodResultIn404.
@Test
public void testNoMatchMethodResultIn404() {
List<String> accessHeaders = List.of("Authorization");
HttpFullRequest req = Requests.createCorsRequest("http://notallowed.domain.com", "/noMethodsSupportCors", accessHeaders, KnownHttpMethod.PUT);
XFuture<HttpFullResponse> respFuture = httpsSocket.send(req);
ResponseWrapper response = ResponseExtract.waitResponseAndWrap(respFuture);
response.assertStatusCode(KnownStatusCode.HTTP_404_NOTFOUND);
}
use of org.webpieces.httpclient11.api.HttpFullResponse in project webpieces by deanhiller.
the class TestGetCorsRouting method testCookie200Ok.
@Test
public void testCookie200Ok() {
String cookieValue = "key1=value1;key2=value2";
List<String> accessHeaders = List.of("Authorization", "asfsf");
HttpFullRequest req = Requests.createCorsRequestCookie(CorsForTwoDomains.DOMAIN1, "/content", accessHeaders, KnownHttpMethod.PUT, cookieValue);
XFuture<HttpFullResponse> respFuture = httpsSocket.send(req);
ResponseWrapper response = ResponseExtract.waitResponseAndWrap(respFuture);
response.assertStatusCode(KnownStatusCode.HTTP_200_OK);
}
Aggregations