use of org.neo4j.server.rest.web.InternalJettyServletRequest in project neo4j by neo4j.
the class BatchOperationsTest method shouldForwardMetadataFromRequestData.
@Test
public void shouldForwardMetadataFromRequestData() throws Exception {
// Given
RequestData mock = new RequestData("127.0.0.1", true, 1, "TheLocalName", "129.0.0.1", 2, "authorization/auth");
InternalJettyServletRequest req = new InternalJettyServletRequest("POST", "https://localhost:7473/db/data/node", "", new InternalJettyServletResponse(), mock);
// When & then
assertEquals("127.0.0.1", req.getRemoteAddr());
assertException(() -> req.getRemoteHost(), UnsupportedOperationException.class, "Remote host-name lookup might prove expensive, this should be explicitly considered.");
assertTrue(req.isSecure());
assertEquals(1, req.getRemotePort());
assertEquals("TheLocalName", req.getLocalName());
assertEquals("129.0.0.1", req.getLocalAddr());
assertEquals(2, req.getLocalPort());
assertEquals("authorization/auth", req.getAuthType());
}
use of org.neo4j.server.rest.web.InternalJettyServletRequest in project neo4j by neo4j.
the class BatchOperations method performRequest.
protected void performRequest(UriInfo uriInfo, String method, String path, String body, Integer id, HttpHeaders httpHeaders, Map<Integer, String> locations, RequestData requestData) throws IOException, ServletException {
path = replaceLocationPlaceholders(path, locations);
body = replaceLocationPlaceholders(body, locations);
URI targetUri = calculateTargetUri(uriInfo, path);
InternalJettyServletResponse res = new InternalJettyServletResponse();
InternalJettyServletRequest req = new InternalJettyServletRequest(method, targetUri.toString(), body, res, requestData);
req.setScheme(targetUri.getScheme());
addHeaders(req, httpHeaders);
invoke(method, path, body, id, targetUri, req, res);
}
use of org.neo4j.server.rest.web.InternalJettyServletRequest in project neo4j by neo4j.
the class BatchOperationsTest method testSchemeInInternalJettyServletRequestForHttps.
@Test
public void testSchemeInInternalJettyServletRequestForHttps() throws UnsupportedEncodingException {
// when
InternalJettyServletRequest req = new InternalJettyServletRequest("POST", "https://localhost:7473/db/data/node", "{'name':'node1'}", new InternalJettyServletResponse(), mock(RequestData.class));
// then
assertEquals("https", req.getScheme());
}
use of org.neo4j.server.rest.web.InternalJettyServletRequest in project neo4j by neo4j.
the class BatchOperationsTest method testSchemeInInternalJettyServletRequestForHttp.
@Test
public void testSchemeInInternalJettyServletRequestForHttp() throws UnsupportedEncodingException {
// when
InternalJettyServletRequest req = new InternalJettyServletRequest("POST", "http://localhost:7473/db/data/node", "{'name':'node1'}", new InternalJettyServletResponse(), mock(RequestData.class));
// then
assertEquals("http", req.getScheme());
}
Aggregations