use of com.sun.jersey.core.header.InBoundHeaders in project neo4j by neo4j.
the class XForwardFilterTest method shouldSetTheBaseUriToTheSameProtocolAsTheXForwardProtoHeader.
@Test
public void shouldSetTheBaseUriToTheSameProtocolAsTheXForwardProtoHeader() throws Exception {
// given
final String theProtocol = "https";
XForwardFilter filter = new XForwardFilter();
InBoundHeaders headers = new InBoundHeaders();
headers.add(X_FORWARD_PROTO_HEADER_KEY, theProtocol);
ContainerRequest request = new ContainerRequest(WEB_APPLICATION, "GET", URI.create("http://jimwebber.org:1234"), URI.create("http://jimwebber.org:1234/foo/bar"), headers, INPUT_STREAM);
// when
ContainerRequest result = filter.filter(request);
// then
assertThat(result.getBaseUri().getScheme(), containsString(theProtocol));
}
use of com.sun.jersey.core.header.InBoundHeaders in project ORCID-Source by ORCID.
the class APIEndpointParserTest method getRequest.
private ContainerRequest getRequest(String url) {
InBoundHeaders headers = new InBoundHeaders();
headers.add(HttpHeaders.CONTENT_TYPE, "application/xml");
headers.add(HttpHeaders.USER_AGENT, "blah");
headers.add("X-FORWARDED-FOR", "37.14.150.83");
return new ContainerRequest(new WebApplicationImpl(), "POST", URI.create("https://localhost:8443/orcid-api-web/"), URI.create(url), headers, null);
}
use of com.sun.jersey.core.header.InBoundHeaders in project ORCID-Source by ORCID.
the class ApiVersionCheckFilterTest method api1_2VersionTest.
@Test
public void api1_2VersionTest() {
WebApplication webApp = Mockito.mock(WebApplication.class, Mockito.RETURNS_MOCKS);
URI baseUri = URI.create("http://localhost:8443/orcid-api-web/");
URI requestUri = URI.create("http://localhost:8443/orcid-api-web/v1.2/0000-0001-7510-9252/activities");
InBoundHeaders headers = new InBoundHeaders();
ByteArrayInputStream inputStream = new ByteArrayInputStream(new byte[0]);
try {
ContainerRequest containerRequest = new ContainerRequest(webApp, "POST", baseUri, requestUri, headers, inputStream);
ApiVersionCheckFilter filter = getApiVersionCheckFilter("http");
filter.filter(containerRequest);
} catch (Exception e) {
fail();
}
try {
ContainerRequest containerRequest = new ContainerRequest(webApp, "PUT", baseUri, requestUri, headers, inputStream);
ApiVersionCheckFilter filter = getApiVersionCheckFilter("http");
filter.filter(containerRequest);
} catch (Exception e) {
fail();
}
try {
ContainerRequest containerRequest = new ContainerRequest(webApp, "DELETE", baseUri, requestUri, headers, inputStream);
ApiVersionCheckFilter filter = getApiVersionCheckFilter("http");
filter.filter(containerRequest);
} catch (Exception e) {
fail();
}
try {
ContainerRequest containerRequest = new ContainerRequest(webApp, "GET", baseUri, requestUri, headers, inputStream);
ApiVersionCheckFilter filter = getApiVersionCheckFilter("http");
filter.filter(containerRequest);
} catch (Exception e) {
fail();
}
}
use of com.sun.jersey.core.header.InBoundHeaders in project ORCID-Source by ORCID.
the class ApiVersionCheckFilterTest method api2_0_rc4VersionTest.
@Test
public void api2_0_rc4VersionTest() {
MockHttpServletRequest mockReq = new MockHttpServletRequest();
mockReq.setAttribute("X-Forwarded-Proto", "https");
OrcidHttpServletRequestWrapper requestWrapper = new OrcidHttpServletRequestWrapper(mockReq);
WebApplication webApp = Mockito.mock(WebApplication.class, Mockito.RETURNS_MOCKS);
URI baseUri = URI.create("http://localhost:8443/orcid-api-web/");
URI requestUri = URI.create("http://localhost:8443/orcid-api-web/v2.0_rc4/0000-0001-7510-9252/activities");
InBoundHeaders headers = new InBoundHeaders();
ByteArrayInputStream inputStream = new ByteArrayInputStream(new byte[0]);
try {
ContainerRequest containerRequest = new ContainerRequest(webApp, "POST", baseUri, requestUri, headers, inputStream);
ApiVersionCheckFilter filter = new ApiVersionCheckFilter(requestWrapper);
filter.filter(containerRequest);
} catch (Exception e) {
fail();
}
try {
ContainerRequest containerRequest = new ContainerRequest(webApp, "PUT", baseUri, requestUri, headers, inputStream);
ApiVersionCheckFilter filter = new ApiVersionCheckFilter(requestWrapper);
filter.filter(containerRequest);
} catch (Exception e) {
fail();
}
try {
ContainerRequest containerRequest = new ContainerRequest(webApp, "DELETE", baseUri, requestUri, headers, inputStream);
ApiVersionCheckFilter filter = new ApiVersionCheckFilter(requestWrapper);
filter.filter(containerRequest);
} catch (Exception e) {
fail();
}
try {
ContainerRequest containerRequest = new ContainerRequest(webApp, "GET", baseUri, requestUri, headers, inputStream);
ApiVersionCheckFilter filter = new ApiVersionCheckFilter(requestWrapper);
filter.filter(containerRequest);
} catch (Exception e) {
fail();
}
}
use of com.sun.jersey.core.header.InBoundHeaders in project ORCID-Source by ORCID.
the class ApiVersionCheckFilterTest method apiOauthTokenTest.
@Test
public void apiOauthTokenTest() {
MockHttpServletRequest mockReq = new MockHttpServletRequest();
mockReq.setAttribute("X-Forwarded-Proto", "https");
OrcidHttpServletRequestWrapper requestWrapper = new OrcidHttpServletRequestWrapper(mockReq);
WebApplication webApp = Mockito.mock(WebApplication.class, Mockito.RETURNS_MOCKS);
URI baseUri = URI.create("http://localhost:8443/orcid-api-web/");
URI requestUri = URI.create("http://localhost:8443/orcid-api-web/oauth/token");
InBoundHeaders headers = new InBoundHeaders();
ByteArrayInputStream inputStream = new ByteArrayInputStream(new byte[0]);
try {
ContainerRequest containerRequest = new ContainerRequest(webApp, "POST", baseUri, requestUri, headers, inputStream);
ApiVersionCheckFilter filter = new ApiVersionCheckFilter(requestWrapper);
filter.filter(containerRequest);
} catch (Exception e) {
fail();
}
}
Aggregations