use of org.neo4j.doc.server.helpers.FunctionalTestHelper in project neo4j-documentation by neo4j.
the class NeoServerDefaultPortAndHostnameDocIT method shouldDefaultToSensiblePortIfNoneSpecifiedInConfig.
@Test
public void shouldDefaultToSensiblePortIfNoneSpecifiedInConfig() throws Exception {
FunctionalTestHelper functionalTestHelper = new FunctionalTestHelper(server());
JaxRsResponse response = functionalTestHelper.get(functionalTestHelper.managementUri());
assertThat(response.getStatus(), is(200));
}
use of org.neo4j.doc.server.helpers.FunctionalTestHelper in project neo4j-documentation by neo4j.
the class SecurityRulesDocIT method shouldInvokeAllSecurityRules.
@Test
public void shouldInvokeAllSecurityRules() throws Exception {
// given
server = CommunityServerBuilder.server().withDefaultDatabaseTuning().withSecurityRules(NoAccessToDatabaseSecurityRule.class.getCanonicalName()).usingDataDir(folder.directory(name.getMethodName()).getAbsolutePath()).build();
server.start();
functionalTestHelper = new FunctionalTestHelper(server);
// when
gen.get().expectedStatus(401).get(functionalTestHelper.dataUri()).response();
// then
assertTrue(NoAccessToDatabaseSecurityRule.wasInvoked());
}
use of org.neo4j.doc.server.helpers.FunctionalTestHelper in project neo4j-documentation by neo4j.
the class SecurityRulesDocIT method should401WithBasicChallengeIfAnyOneOfTheRulesFails.
@Test
public void should401WithBasicChallengeIfAnyOneOfTheRulesFails() throws Exception {
server = CommunityServerBuilder.server().withDefaultDatabaseTuning().withSecurityRules(PermanentlyFailingSecurityRule.class.getCanonicalName(), PermanentlyPassingSecurityRule.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.doc.server.helpers.FunctionalTestHelper in project neo4j-documentation by neo4j.
the class SecurityRulesDocIT method aSimpleWildcardUriPathShould401OnAccessToProtectedSubPath.
@Test
@Title("Using wildcards to target security rules")
@Documented("In this example, a security rule is registered to deny access to all URIs to the server by listing the rule(s) class(es) in _neo4j.conf_.\n" + "In this case, the rule is registered using a wildcard URI path (where `*` characters can be used to signify any part of the path).\n" + "For example `/users*` means the rule will be bound to any resources under the `/users` root path.\n" + "Similarly `/users*type*` will bind the rule to resources matching 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 denied by the server.\n" + "Using wildcards allows flexible targeting of security rules to arbitrary parts of the server's API, including any unmanaged extensions or managed 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.doc.web.service", mountPoint).withSecurityRules(PermanentlyFailingSecurityRuleWithWildcardPath.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" + ".PermanentlyFailingSecurityRuleWithWildcardPath\n----\n");
gen.get().addTestSourceSnippets(PermanentlyFailingSecurityRuleWithWildcardPath.class, "failingRuleWithWildcardPath");
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());
}
use of org.neo4j.doc.server.helpers.FunctionalTestHelper in project neo4j-documentation by neo4j.
the class ManageNodeDocIT method setupServer.
@BeforeClass
public static void setupServer() throws IOException {
functionalTestHelper = new FunctionalTestHelper(server());
helper = functionalTestHelper.getGraphDbHelper();
}
Aggregations