use of org.neo4j.server.rest.JaxRsResponse in project neo4j by neo4j.
the class CollectUserAgentFilterIT method sendRequest.
private void sendRequest(String userAgent) {
String url = functionalTestHelper.baseUri().toString();
JaxRsResponse resp = RestRequest.req().header("User-Agent", userAgent).get(url);
String json = resp.getEntity();
resp.close();
assertEquals(json, 200, resp.getStatus());
}
use of org.neo4j.server.rest.JaxRsResponse in project neo4j by neo4j.
the class SecurityRulesIT method should401WithBasicChallengeWhenASecurityRuleFails.
@Test
@Title("Enforcing Server Authorization Rules")
@Documented("In this example, a (dummy) failing security rule is registered to deny\n" + "access to all URIs to the server by listing the rules class in\n" + "'neo4j.conf':\n" + "\n" + "@@config\n" + "\n" + "with the rule source code of:\n" + "\n" + "@@failingRule\n" + "\n" + "With this rule registered, any access to the server will be\n" + "denied. In a production-quality implementation the rule\n" + "will likely lookup credentials/claims in a 3rd-party\n" + "directory service (e.g. LDAP) or in a local database of\n" + "authorized users.")
public void should401WithBasicChallengeWhenASecurityRuleFails() throws Exception {
server = CommunityServerBuilder.server().withDefaultDatabaseTuning().withSecurityRules(PermanentlyFailingSecurityRule.class.getCanonicalName()).usingDataDir(folder.directory(name.getMethodName()).getAbsolutePath()).build();
server.start();
functionalTestHelper = new FunctionalTestHelper(server);
JaxRsResponse response = gen.get().expectedStatus(401).expectedHeader("WWW-Authenticate").post(functionalTestHelper.nodeUri()).response();
assertThat(response.getHeaders().getFirst("WWW-Authenticate"), containsString("Basic realm=\"" + PermanentlyFailingSecurityRule.REALM + "\""));
}
use of org.neo4j.server.rest.JaxRsResponse in project neo4j by neo4j.
the class StreamingBatchOperationIT method shouldRollbackAllWhenInsertingIllegalData.
@Test
public void shouldRollbackAllWhenInsertingIllegalData() throws JsonParseException, ClientHandlerException, UniformInterfaceException, JSONException {
String jsonString = new PrettyJSON().array().object().key("method").value("POST").key("to").value("/node").key("body").object().key("age").value(1).endObject().endObject().object().key("method").value("POST").key("to").value("/node").key("body").object().key("age").object().key("age").value(1).endObject().endObject().endObject().endArray().toString();
long originalNodeCount = countNodes();
JaxRsResponse response = RestRequest.req().accept(APPLICATION_JSON_TYPE).header(StreamingFormat.STREAM_HEADER, "true").post(batchUri(), jsonString);
assertEquals(200, response.getStatus());
assertEquals(400, singleResult(response, 1).get("status"));
assertEquals(originalNodeCount, countNodes());
}
use of org.neo4j.server.rest.JaxRsResponse in project neo4j by neo4j.
the class StreamingBatchOperationIT method shouldRollbackAllOnSingle404.
@Test
public void shouldRollbackAllOnSingle404() throws JsonParseException, ClientHandlerException, UniformInterfaceException, JSONException {
String jsonString = new PrettyJSON().array().object().key("method").value("POST").key("to").value("/node").key("body").object().key("age").value(1).endObject().endObject().object().key("method").value("POST").key("to").value("www.google.com").endObject().endArray().toString();
long originalNodeCount = countNodes();
JaxRsResponse response = RestRequest.req().accept(APPLICATION_JSON_TYPE).header(StreamingFormat.STREAM_HEADER, "true").post(batchUri(), jsonString);
assertEquals(200, response.getStatus());
assertEquals(404, singleResult(response, 1).get("status"));
assertEquals(originalNodeCount, countNodes());
}
use of org.neo4j.server.rest.JaxRsResponse in project neo4j by neo4j.
the class StreamingBatchOperationIT method shouldBeAbleToReferToUniquelyCreatedEntities.
@Test
public void shouldBeAbleToReferToUniquelyCreatedEntities() throws Exception {
String jsonString = new PrettyJSON().array().object().key("method").value("POST").key("to").value("/index/node/Cultures?unique").key("body").object().key("key").value("ID").key("value").value("fra").key("properties").object().key("ID").value("fra").endObject().endObject().key("id").value(0).endObject().object().key("method").value("POST").key("to").value("/node").key("id").value(1).endObject().object().key("method").value("POST").key("to").value("{1}/relationships").key("body").object().key("to").value("{0}").key("type").value("has").endObject().key("id").value(2).endObject().endArray().toString();
JaxRsResponse response = RestRequest.req().accept(APPLICATION_JSON_TYPE).header(StreamingFormat.STREAM_HEADER, "true").post(batchUri(), jsonString);
assertEquals(200, response.getStatus());
}
Aggregations