use of com.sun.jersey.spi.container.ContainerRequest 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.spi.container.ContainerRequest in project ORCID-Source by ORCID.
the class APIEndpointParserTest method testAPIEndpointParserNoCategoryV2.
@Test
public void testAPIEndpointParserNoCategoryV2() {
ContainerRequest request = getRequest("https://localhost:8443/orcid-api-web/v2.0/1234-4321-1234-4321");
APIEndpointParser parser = new APIEndpointParser(request);
assertEquals("v2.0", parser.getApiVersion());
assertEquals("record", parser.getCategory());
assertEquals("1234-4321-1234-4321", parser.getOrcidId());
}
use of com.sun.jersey.spi.container.ContainerRequest 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.spi.container.ContainerRequest in project ORCID-Source by ORCID.
the class APIEndpointParserTest method testAPIEndpointParserNoCategoryOrVersion.
@Test
public void testAPIEndpointParserNoCategoryOrVersion() {
ContainerRequest request = getRequest("https://localhost:8443/orcid-api-web/1234-4321-1234-4321");
APIEndpointParser parser = new APIEndpointParser(request);
assertNotNull(parser.getApiVersion());
assertEquals("", parser.getApiVersion());
assertEquals("orcid-bio", parser.getCategory());
assertEquals("1234-4321-1234-4321", parser.getOrcidId());
}
use of com.sun.jersey.spi.container.ContainerRequest in project ORCID-Source by ORCID.
the class TokenTargetFilterTest method tokenUsedOnTheRightUserTest.
@Test
public void tokenUsedOnTheRightUserTest() {
setUpSecurityContext(ORCID1, CLIENT_ID, ScopePathType.READ_LIMITED);
ContainerRequest request = Mockito.mock(ContainerRequest.class);
Mockito.when(request.getPath()).thenReturn("http://api.test.orcid.org/v2.0/" + ORCID1);
TokenTargetFilter filter = new TokenTargetFilter();
filter.filter(request);
}
Aggregations