use of org.neo4j.kernel.impl.annotations.Documented 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.kernel.impl.annotations.Documented in project neo4j by neo4j.
the class TransactionTest method execute_multiple_statements.
@Test
@Documented("Execute multiple statements\n" + "\n" + "You can send multiple Cypher statements in the same request.\n" + "The response will contain the result of each statement.")
public void execute_multiple_statements() throws JsonParseException {
// Document
ResponseEntity response = gen.get().expectedStatus(200).payload(quotedJson("{ 'statements': [ { 'statement': 'CREATE (n) RETURN id(n)' }, " + "{ 'statement': 'CREATE (n {props}) RETURN n', " + "'parameters': { 'props': { 'name': 'My Node' } } } ] }")).post(getDataUri() + "transaction/commit");
// Then
Map<String, Object> result = jsonToMap(response.entity());
assertNoErrors(result);
Integer id = resultCell(result, 0, 0);
assertThat(GET(getNodeUri(id)).status(), is(200));
assertThat(response.entity(), containsString("My Node"));
}
use of org.neo4j.kernel.impl.annotations.Documented in project neo4j by neo4j.
the class UsersIT method user_status_first_access.
@Test
@Documented("User status on first access\n" + "\n" + "On first access, and using the default password, the user status will indicate that the users password requires changing.")
public void user_status_first_access() throws JsonParseException, IOException {
// Given
startServer(true);
// Document
RESTRequestGenerator.ResponseEntity response = gen.get().expectedStatus(200).withHeader(HttpHeaders.AUTHORIZATION, challengeResponse("neo4j", "neo4j")).get(userURL("neo4j"));
// Then
JsonNode data = JsonHelper.jsonNode(response.entity());
assertThat(data.get("username").asText(), equalTo("neo4j"));
assertThat(data.get("password_change_required").asBoolean(), equalTo(true));
assertThat(data.get("password_change").asText(), equalTo(passwordURL("neo4j")));
}
use of org.neo4j.kernel.impl.annotations.Documented in project neo4j by neo4j.
the class UsersIT method user_status.
@Test
@Documented("User status\n" + "\n" + "Given that you know the current password, you can ask the server for the user status.")
public void user_status() throws JsonParseException, IOException {
// Given
startServerWithConfiguredUser();
// Document
RESTRequestGenerator.ResponseEntity response = gen.get().expectedStatus(200).withHeader(HttpHeaders.AUTHORIZATION, challengeResponse("neo4j", "secret")).get(userURL("neo4j"));
// Then
JsonNode data = JsonHelper.jsonNode(response.entity());
assertThat(data.get("username").asText(), equalTo("neo4j"));
assertThat(data.get("password_change_required").asBoolean(), equalTo(false));
assertThat(data.get("password_change").asText(), equalTo(passwordURL("neo4j")));
}
use of org.neo4j.kernel.impl.annotations.Documented in project neo4j by neo4j.
the class TraverserIT method shouldGetExpectedHitsWhenTraversingAtDepth.
@Documented("Traversal returning nodes below a certain depth.\n" + "\n" + "Here, all nodes at a traversal depth below 3 are returned.")
@Graph({ "Root knows Mattias", "Root knows Johan", "Johan knows Emil", "Emil knows Peter", "Emil knows Tobias", "Tobias loves Sara" })
@Test
public void shouldGetExpectedHitsWhenTraversingAtDepth() throws JsonParseException {
Node start = getNode("Root");
String description = createJsonFrom(map("prune_evaluator", map("language", "builtin", "name", "none"), "return_filter", map("language", "javascript", "body", "position.length()<3;")));
String entity = gen().expectedStatus(200).payload(description).post(getTraverseUriNodes(start)).entity();
expectNodes(entity, getNodes("Root", "Mattias", "Johan", "Emil"));
}
Aggregations