use of org.neo4j.server.rest.JaxRsResponse in project neo4j by neo4j.
the class BatchOperationHeaderIT method shouldPassHeaders.
@Test
public void shouldPassHeaders() throws Exception {
String jsonData = new PrettyJSON().array().object().key("method").value("GET").key("to").value("../.." + DUMMY_WEB_SERVICE_MOUNT_POINT + "/needs-auth-header").key("body").object().endObject().endObject().endArray().toString();
JaxRsResponse response = new RestRequest(null, "user", "pass").post("http://localhost:7474/db/data/batch", jsonData);
assertEquals(200, response.getStatus());
final List<Map<String, Object>> responseData = jsonToList(response.getEntity());
Map<String, Object> res = (Map<String, Object>) responseData.get(0).get("body");
/*
* {
* Accept=[application/json],
* Content-Type=[application/json],
* Authorization=[Basic dXNlcjpwYXNz],
* User-Agent=[Java/1.6.0_27] <-- ignore that, it changes often
* Host=[localhost:7474],
* Connection=[keep-alive],
* Content-Length=[86]
* }
*/
assertEquals("Basic dXNlcjpwYXNz", res.get("Authorization"));
assertEquals("application/json", res.get("Accept"));
assertEquals("application/json", res.get("Content-Type"));
assertEquals("localhost:7474", res.get("Host"));
assertEquals("keep-alive", res.get("Connection"));
}
use of org.neo4j.server.rest.JaxRsResponse in project neo4j by neo4j.
the class BoltIT method boltPortShouldComeFromConfigButHostShouldMatchHttpHostHeaderWhenConfigIsLocalhostOrEmptyEvenThoughThisIsMorallyHazardous.
@Test
public void boltPortShouldComeFromConfigButHostShouldMatchHttpHostHeaderWhenConfigIsLocalhostOrEmptyEvenThoughThisIsMorallyHazardous() throws Throwable {
// Given
String host = "neo4j.com";
startServerWithBoltEnabled("localhost", 9999, "localhost", 7687);
RestRequest request = new RestRequest(server.baseUri()).host(host);
// When
JaxRsResponse response = request.get();
// Then
Map<String, Object> map = JsonHelper.jsonToMap(response.getEntity());
assertThat(String.valueOf(map.get("bolt")), containsString("bolt://" + host + ":9999"));
}
use of org.neo4j.server.rest.JaxRsResponse in project neo4j by neo4j.
the class ServerConfigIT method shouldPickUpAddressFromConfig.
@Test
public void shouldPickUpAddressFromConfig() throws Exception {
ListenSocketAddress nonDefaultAddress = new ListenSocketAddress("0.0.0.0", 4321);
server = server().onAddress(nonDefaultAddress).usingDataDir(folder.directory(name.getMethodName()).getAbsolutePath()).build();
server.start();
assertEquals(nonDefaultAddress, server.getAddress());
JaxRsResponse response = new RestRequest(server.baseUri()).get();
assertThat(response.getStatus(), is(200));
response.close();
}
use of org.neo4j.server.rest.JaxRsResponse in project neo4j by neo4j.
the class ServerConfigIT method shouldHaveSandboxingEnabledByDefault.
@Test
public void shouldHaveSandboxingEnabledByDefault() throws Exception {
// Given
server = server().usingDataDir(folder.directory(name.getMethodName()).getAbsolutePath()).build();
server.start();
String node = POST(server.baseUri().toASCIIString() + "db/data/node").location();
// When
JaxRsResponse response = new RestRequest().post(node + "/traverse/node", "{\n" + " \"order\" : \"breadth_first\",\n" + " \"return_filter\" : {\n" + " \"body\" : \"position.getClass().getClassLoader()\",\n" + " \"language\" : \"javascript\"\n" + " },\n" + " \"prune_evaluator\" : {\n" + " \"body\" : \"position.getClass().getClassLoader()\",\n" + " \"language\" : \"javascript\"\n" + " },\n" + " \"uniqueness\" : \"node_global\",\n" + " \"relationships\" : [ {\n" + " \"direction\" : \"all\",\n" + " \"type\" : \"knows\"\n" + " }, {\n" + " \"direction\" : \"all\",\n" + " \"type\" : \"loves\"\n" + " } ],\n" + " \"max_depth\" : 3\n" + "}", MediaType.APPLICATION_JSON_TYPE);
// Then
assertEquals(400, response.getStatus());
}
use of org.neo4j.server.rest.JaxRsResponse in project neo4j by neo4j.
the class ServerConfigIT method shouldGenerateWADLWhenExplicitlyEnabledInConfig.
@Test
public void shouldGenerateWADLWhenExplicitlyEnabledInConfig() throws IOException {
server = server().withProperty(ServerSettings.wadl_enabled.name(), "true").usingDataDir(folder.directory(name.getMethodName()).getAbsolutePath()).build();
server.start();
JaxRsResponse response = new RestRequest().get("http://localhost:7474/application.wadl", MediaType.WILDCARD_TYPE);
assertEquals(200, response.getStatus());
assertEquals("application/vnd.sun.wadl+xml", response.getHeaders().get("Content-Type").iterator().next());
assertThat(response.getEntity(), containsString("<application xmlns=\"http://wadl.dev.java" + ".net/2009/02\">"));
}
Aggregations