use of org.codehaus.jackson.JsonNode in project neo4j by neo4j.
the class AuthenticationIT method password_change_required.
@Test
@Documented("Required password changes\n" + "\n" + "In some cases, like the very first time Neo4j is accessed, the user will be required to choose\n" + "a new password. The database will signal that a new password is required and deny access.\n" + "\n" + "See <<rest-api-security-user-status-and-password-changing>> for how to set a new password.")
public void password_change_required() throws JsonParseException, IOException {
// Given
startServer(true);
// Document
RESTRequestGenerator.ResponseEntity response = gen.get().expectedStatus(403).withHeader(HttpHeaders.AUTHORIZATION, challengeResponse("neo4j", "neo4j")).get(dataURL());
// Then
JsonNode data = JsonHelper.jsonNode(response.entity());
JsonNode firstError = data.get("errors").get(0);
assertThat(firstError.get("code").asText(), equalTo("Neo.ClientError.Security.Forbidden"));
assertThat(firstError.get("message").asText(), equalTo("User is required to change their password."));
assertThat(data.get("password_change").asText(), equalTo(passwordURL("neo4j")));
}
use of org.codehaus.jackson.JsonNode in project neo4j by neo4j.
the class GraphExtractionWriterTest method assertNode.
// Helpers
private static void assertNode(String id, JsonNode nodes, List<String> labels, Property... properties) {
JsonNode node = get(nodes, id);
assertListEquals("Node[" + id + "].labels", labels, node.get("labels"));
JsonNode props = node.get("properties");
assertEquals("length( Node[" + id + "].properties )", properties.length, props.size());
for (Property property : properties) {
assertJsonEquals("Node[" + id + "].properties[" + property.key() + "]", property.value(), props.get(property.key()));
}
}
use of org.codehaus.jackson.JsonNode 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.codehaus.jackson.JsonNode 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.codehaus.jackson.JsonNode in project neo4j by neo4j.
the class RestRepresentationWriterTests method shouldWriteNestedMaps.
@Test
public void shouldWriteNestedMaps() throws Exception {
ByteArrayOutputStream out = new ByteArrayOutputStream();
JsonGenerator json = new JsonFactory(new Neo4jJsonCodec()).createJsonGenerator(out);
JsonNode rest = serialize(out, json, new RestRepresentationWriter(URI.create("localhost")));
MatcherAssert.assertThat(rest.size(), equalTo(1));
JsonNode firstCell = rest.get(0);
MatcherAssert.assertThat(firstCell.get("one").get("two").size(), is(2));
MatcherAssert.assertThat(firstCell.get("one").get("two").get(0).asBoolean(), is(true));
MatcherAssert.assertThat(firstCell.get("one").get("two").get(1).get("three").asInt(), is(42));
}
Aggregations