Search in sources :

Example 1 with XForwardFilter

use of org.neo4j.server.web.XForwardFilter 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));
}
Also used : InBoundHeaders(com.sun.jersey.core.header.InBoundHeaders) XForwardFilter(org.neo4j.server.web.XForwardFilter) ContainerRequest(com.sun.jersey.spi.container.ContainerRequest) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Test(org.junit.Test)

Example 2 with XForwardFilter

use of org.neo4j.server.web.XForwardFilter in project neo4j by neo4j.

the class XForwardFilterTest method shouldSetTheRequestUriToTheSameProtocolAsTheXForwardProtoHeader.

@Test
public void shouldSetTheRequestUriToTheSameProtocolAsTheXForwardProtoHeader() 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));
}
Also used : InBoundHeaders(com.sun.jersey.core.header.InBoundHeaders) XForwardFilter(org.neo4j.server.web.XForwardFilter) ContainerRequest(com.sun.jersey.spi.container.ContainerRequest) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Test(org.junit.Test)

Example 3 with XForwardFilter

use of org.neo4j.server.web.XForwardFilter in project neo4j by neo4j.

the class XForwardFilterTest method shouldSetTheBaseUriToTheSameValueAsTheXForwardHostHeader.

@Test
public void shouldSetTheBaseUriToTheSameValueAsTheXForwardHostHeader() throws Exception {
    // given
    final String xForwardHostAndPort = "jimwebber.org:1234";
    XForwardFilter filter = new XForwardFilter();
    InBoundHeaders headers = new InBoundHeaders();
    headers.add(X_FORWARD_HOST_HEADER_KEY, xForwardHostAndPort);
    ContainerRequest request = new ContainerRequest(WEB_APPLICATION, "GET", URI.create("http://iansrobinson.com"), URI.create("http://iansrobinson.com/foo/bar"), headers, INPUT_STREAM);
    // when
    ContainerRequest result = filter.filter(request);
    // then
    assertThat(result.getBaseUri().toString(), containsString(xForwardHostAndPort));
}
Also used : InBoundHeaders(com.sun.jersey.core.header.InBoundHeaders) XForwardFilter(org.neo4j.server.web.XForwardFilter) ContainerRequest(com.sun.jersey.spi.container.ContainerRequest) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Test(org.junit.Test)

Example 4 with XForwardFilter

use of org.neo4j.server.web.XForwardFilter in project neo4j by neo4j.

the class XForwardFilterTest method shouldSetTheRequestUriToTheSameValueAsTheXForwardHostHeader.

@Test
public void shouldSetTheRequestUriToTheSameValueAsTheXForwardHostHeader() throws Exception {
    // given
    final String xForwardHostAndPort = "jimwebber.org:1234";
    XForwardFilter filter = new XForwardFilter();
    InBoundHeaders headers = new InBoundHeaders();
    headers.add(X_FORWARD_HOST_HEADER_KEY, xForwardHostAndPort);
    ContainerRequest request = new ContainerRequest(WEB_APPLICATION, "GET", URI.create("http://iansrobinson.com"), URI.create("http://iansrobinson.com/foo/bar"), headers, INPUT_STREAM);
    // when
    ContainerRequest result = filter.filter(request);
    // then
    assertTrue(result.getRequestUri().toString().startsWith("http://" + xForwardHostAndPort));
}
Also used : InBoundHeaders(com.sun.jersey.core.header.InBoundHeaders) XForwardFilter(org.neo4j.server.web.XForwardFilter) ContainerRequest(com.sun.jersey.spi.container.ContainerRequest) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Test(org.junit.Test)

Aggregations

InBoundHeaders (com.sun.jersey.core.header.InBoundHeaders)4 ContainerRequest (com.sun.jersey.spi.container.ContainerRequest)4 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)4 Test (org.junit.Test)4 XForwardFilter (org.neo4j.server.web.XForwardFilter)4