use of org.neo4j.doc.server.rest.JaxRsResponse in project neo4j-documentation by neo4j.
the class PagedTraverserDocIT method shouldRespondWith400OnNegativeLeaseTime.
@Test
public void shouldRespondWith400OnNegativeLeaseTime() {
theStartNode = createLinkedList(SHORT_LIST_LENGTH, server.getDatabase());
int negativeLeaseTime = -9;
JaxRsResponse response = RestRequest.req().post(functionalTestHelper.nodeUri(theStartNode.getId()) + "/paged/traverse/node?leaseTime=" + String.valueOf(negativeLeaseTime), traverserDescription());
assertEquals(400, response.getStatus());
}
use of org.neo4j.doc.server.rest.JaxRsResponse in project neo4j-documentation by neo4j.
the class PagedTraverserDocIT method shouldRespondWith400OnScriptErrors.
@Test
public void shouldRespondWith400OnScriptErrors() {
GlobalJavascriptInitializer.initialize(ScriptExecutionMode.SANDBOXED);
theStartNode = createLinkedList(1, server.getDatabase());
JaxRsResponse response = RestRequest.req().post(functionalTestHelper.nodeUri(theStartNode.getId()) + "/paged/traverse/node?pageSize=50", "{" + "\"prune_evaluator\":{\"language\":\"builtin\",\"name\":\"none\"}," + "\"return_filter\":{\"language\":\"javascript\",\"body\":\"position.getClass()" + ".getClassLoader();\"}," + "\"order\":\"depth_first\"," + "\"relationships\":{\"type\":\"NEXT\",\"direction\":\"out\"}" + "}");
assertEquals(400, response.getStatus());
}
use of org.neo4j.doc.server.rest.JaxRsResponse in project neo4j-documentation by neo4j.
the class PagedTraverserDocIT method shouldHaveTransportEncodingChunkedOnResponseHeader.
@Test
public void shouldHaveTransportEncodingChunkedOnResponseHeader() {
// given
theStartNode = createLinkedList(VERY_LONG_LIST_LENGTH, server.getDatabase());
// when
JaxRsResponse response = createStreamingPagedTraverserWithTimeoutInMinutesAndPageSize(60, 1000);
// then
assertEquals(201, response.getStatus());
assertEquals("application/json; charset=UTF-8; stream=true", response.getHeaders().getFirst("Content-Type"));
assertThat(response.getHeaders().getFirst("Transfer-Encoding"), containsString("chunked"));
}
use of org.neo4j.doc.server.rest.JaxRsResponse in project neo4j-documentation by neo4j.
the class PagedTraverserDocIT method shouldExpireTraverserWithNonDefaultTimeout.
@Documented("Paged traverser timeout.\n\n" + "The default timeout for a paged traverser is 60\n" + "seconds, but depending on the application larger or smaller timeouts\n" + "might be appropriate. This can be set by adding a +leaseTime+ query\n" + "parameter with the number of seconds the paged traverser should last.")
@Test
public void shouldExpireTraverserWithNonDefaultTimeout() {
theStartNode = createLinkedList(SHORT_LIST_LENGTH, server.getDatabase());
URI traverserLocation = createPagedTraverserWithTimeoutInMinutes(10).getLocation();
clock.forward(11, TimeUnit.MINUTES);
JaxRsResponse response = new RestRequest(traverserLocation).get();
assertEquals(404, response.getStatus());
}
use of org.neo4j.doc.server.rest.JaxRsResponse in project neo4j-documentation by neo4j.
the class SecurityRulesDocIT method aComplexWildcardUriPathShould401OnAccessToProtectedSubPath.
@Test
@Title("Using complex wildcards to target security rules")
@Documented("In this example, a security rule is registered to deny access to all URIs matching a complex pattern.\n" + "The config looks like this:\n" + "\n" + "@@config\n" + "\n" + "with the rule source code of:\n" + "\n" + "@@failingRuleWithComplexWildcardPath")
public void aComplexWildcardUriPathShould401OnAccessToProtectedSubPath() throws Exception {
String mountPoint = "/protected/wildcard_replacement/x/y/z/something/else/more_wildcard_replacement/a/b/c" + "/final/bit";
server = CommunityServerBuilder.server().withDefaultDatabaseTuning().withThirdPartyJaxRsPackage("org.dummy.doc.web.service", mountPoint).withSecurityRules(PermanentlyFailingSecurityRuleWithComplexWildcardPath.class.getCanonicalName()).usingDataDir(folder.directory(name.getMethodName()).getAbsolutePath()).build();
server.start();
gen.get().docHeadingLevel(1);
gen.get().addSnippet("config", "\n[source,properties]\n----\ndbms.security.http_authorization_classes=my.rules" + ".PermanentlyFailingSecurityRuleWithComplexWildcardPath\n----\n");
gen.get().addTestSourceSnippets(PermanentlyFailingSecurityRuleWithComplexWildcardPath.class, "failingRuleWithComplexWildcardPath");
gen.get().setSection("ops");
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());
}
Aggregations