Search in sources :

Example 61 with Documented

use of org.neo4j.kernel.impl.annotations.Documented in project neo4j by neo4j.

the class RetrieveRelationshipsFromNodeIT method shouldRespondWith200AndListOfRelationshipRepresentationsWhenGettingIncomingRelationshipsForANode.

@Documented("Get incoming relationships.")
@Test
public void shouldRespondWith200AndListOfRelationshipRepresentationsWhenGettingIncomingRelationshipsForANode() throws JsonParseException {
    String entity = gen.get().expectedStatus(200).get(functionalTestHelper.nodeUri() + "/" + nodeWithRelationships + "/relationships" + "/in").entity();
    verifyRelReps(1, entity);
}
Also used : Matchers.containsString(org.hamcrest.Matchers.containsString) Documented(org.neo4j.kernel.impl.annotations.Documented) RelationshipRepresentationTest(org.neo4j.server.rest.repr.RelationshipRepresentationTest) Test(org.junit.Test)

Example 62 with Documented

use of org.neo4j.kernel.impl.annotations.Documented in project neo4j by neo4j.

the class RetrieveRelationshipsFromNodeIT method shouldRespondWith200AndListOfRelationshipRepresentationsWhenGettingAllTypedRelationshipsForANode.

@Documented("Get typed relationships.\n" + "\n" + "Note that the \"+&+\" needs to be encoded like \"+%26+\" for example when\n" + "using http://curl.haxx.se/[cURL] from the terminal.")
@Test
public void shouldRespondWith200AndListOfRelationshipRepresentationsWhenGettingAllTypedRelationshipsForANode() throws JsonParseException {
    String entity = gen.get().expectedStatus(200).get(functionalTestHelper.nodeUri() + "/" + nodeWithRelationships + "/relationships" + "/all/LIKES&HATES").entity();
    verifyRelReps(3, entity);
}
Also used : Matchers.containsString(org.hamcrest.Matchers.containsString) Documented(org.neo4j.kernel.impl.annotations.Documented) RelationshipRepresentationTest(org.neo4j.server.rest.repr.RelationshipRepresentationTest) Test(org.junit.Test)

Example 63 with Documented

use of org.neo4j.kernel.impl.annotations.Documented in project neo4j by neo4j.

the class PagedTraverserIT method shouldBeAbleToTraverseAllThePagesWithNonDefaultPageSize.

@Documented("Paged traverser page size.\n\n" + "The default page size is 50 items, but\n" + "depending on the application larger or smaller pages sizes might be\n" + "appropriate. This can be set by adding a +pageSize+ query parameter.")
@Test
public void shouldBeAbleToTraverseAllThePagesWithNonDefaultPageSize() {
    theStartNode = createLinkedList(SHORT_LIST_LENGTH, server.getDatabase());
    URI traverserLocation = createPagedTraverserWithPageSize(1).getLocation();
    int enoughPagesToExpireTheTraverser = 12;
    for (int i = 0; i < enoughPagesToExpireTheTraverser; i++) {
        JaxRsResponse response = new RestRequest(traverserLocation).get();
        assertEquals(200, response.getStatus());
    }
    JaxRsResponse response = new RestRequest(traverserLocation).get();
    assertEquals(404, response.getStatus());
}
Also used : RestRequest(org.neo4j.server.rest.RestRequest) JaxRsResponse(org.neo4j.server.rest.JaxRsResponse) URI(java.net.URI) Documented(org.neo4j.kernel.impl.annotations.Documented) Test(org.junit.Test)

Example 64 with Documented

use of org.neo4j.kernel.impl.annotations.Documented in project neo4j by neo4j.

the class PagedTraverserIT method shouldPostATraverserWithDefaultOptionsAndReceiveTheFirstPageOfResults.

@Documented("Creating a paged traverser.\n\n" + "Paged traversers are created by ++POST++-ing a\n" + "traversal description to the link identified by the +paged_traverser+ key\n" + "in a node representation. When creating a paged traverser, the same\n" + "options apply as for a regular traverser, meaning that +node+, +path+,\n" + "or +fullpath+, can be targeted.")
@Test
public void shouldPostATraverserWithDefaultOptionsAndReceiveTheFirstPageOfResults() throws Exception {
    theStartNode = createLinkedList(SHORT_LIST_LENGTH, server.getDatabase());
    ResponseEntity entity = gen.get().expectedType(MediaType.valueOf("application/json; charset=UTF-8")).expectedHeader("Location").expectedStatus(201).payload(traverserDescription()).payloadType(MediaType.APPLICATION_JSON_TYPE).post(functionalTestHelper.nodeUri(theStartNode.getId()) + "/paged/traverse/node");
    assertEquals(201, entity.response().getStatus());
    assertThat(entity.response().getLocation().toString(), containsString("/db/data/node/" + theStartNode.getId() + "/paged/traverse/node/"));
    assertEquals("application/json; charset=UTF-8", entity.response().getType().toString());
}
Also used : ResponseEntity(org.neo4j.server.rest.RESTRequestGenerator.ResponseEntity) Documented(org.neo4j.kernel.impl.annotations.Documented) Test(org.junit.Test)

Example 65 with Documented

use of org.neo4j.kernel.impl.annotations.Documented in project neo4j by neo4j.

the class SecurityRulesIT method aSimpleWildcardUriPathShould401OnAccessToProtectedSubPath.

@Test
@Title("Using Wildcards to Target Security Rules")
@Documented("In this example, a security rule is registered to deny\n" + "access to all URIs to the server by listing the rule(s) class(es) in\n" + "'neo4j.conf'.\n" + "In this case, the rule is registered\n" + "using a wildcard URI path (where `*` characters can be used to signify\n" + "any part of the path). For example `/users*` means the rule\n" + "will be bound to any resources under the `/users` root path. Similarly\n" + "`/users*type*` will bind the rule to resources matching\n" + "URIs like `/users/fred/type/premium`.\n" + "\n" + "@@config\n" + "\n" + "with the rule source code of:\n" + "\n" + "@@failingRuleWithWildcardPath\n" + "\n" + "With this rule registered, any access to URIs under /protected/ will be\n" + "denied by the server. Using wildcards allows flexible targeting of security rules to\n" + "arbitrary parts of the server's API, including any unmanaged extensions or managed\n" + "plugins that have been registered.")
public void aSimpleWildcardUriPathShould401OnAccessToProtectedSubPath() throws Exception {
    String mountPoint = "/protected/tree/starts/here" + DummyThirdPartyWebService.DUMMY_WEB_SERVICE_MOUNT_POINT;
    server = CommunityServerBuilder.server().withDefaultDatabaseTuning().withThirdPartyJaxRsPackage("org.dummy.web.service", mountPoint).withSecurityRules(PermanentlyFailingSecurityRuleWithWildcardPath.class.getCanonicalName()).usingDataDir(folder.directory(name.getMethodName()).getAbsolutePath()).build();
    server.start();
    functionalTestHelper = new FunctionalTestHelper(server);
    JaxRsResponse clientResponse = gen.get().expectedStatus(401).expectedType(MediaType.APPLICATION_JSON_TYPE).expectedHeader("WWW-Authenticate").get(trimTrailingSlash(functionalTestHelper.baseUri()) + mountPoint + "/more/stuff").response();
    assertEquals(401, clientResponse.getStatus());
}
Also used : FunctionalTestHelper(org.neo4j.server.helpers.FunctionalTestHelper) Matchers.containsString(org.hamcrest.Matchers.containsString) JaxRsResponse(org.neo4j.server.rest.JaxRsResponse) Documented(org.neo4j.kernel.impl.annotations.Documented) Test(org.junit.Test) Title(org.neo4j.test.TestData.Title)

Aggregations

Documented (org.neo4j.kernel.impl.annotations.Documented)71 Test (org.junit.Test)70 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)26 Graph (org.neo4j.test.GraphDescription.Graph)21 ResponseEntity (org.neo4j.server.rest.RESTRequestGenerator.ResponseEntity)20 Title (org.neo4j.test.TestData.Title)19 Node (org.neo4j.graphdb.Node)14 Matchers.containsString (org.hamcrest.Matchers.containsString)11 Transaction (org.neo4j.graphdb.Transaction)8 RelationshipRepresentationTest (org.neo4j.server.rest.repr.RelationshipRepresentationTest)7 JsonNode (org.codehaus.jackson.JsonNode)6 JaxRsResponse (org.neo4j.server.rest.JaxRsResponse)6 RESTRequestGenerator (org.neo4j.server.rest.RESTRequestGenerator)6 ArrayList (java.util.ArrayList)5 GraphDatabaseService (org.neo4j.graphdb.GraphDatabaseService)5 Relationship (org.neo4j.graphdb.Relationship)5 Map (java.util.Map)4 URI (java.net.URI)3 FunctionalTestHelper (org.neo4j.server.helpers.FunctionalTestHelper)3 RestRequest (org.neo4j.server.rest.RestRequest)3