Search in sources :

Example 1 with FunctionalTestHelper

use of org.neo4j.server.helpers.FunctionalTestHelper in project neo4j by neo4j.

the class GetRelationshipPropertiesIT method setupServer.

@BeforeClass
public static void setupServer() throws IOException {
    functionalTestHelper = new FunctionalTestHelper(server());
    helper = functionalTestHelper.getGraphDbHelper();
    setupTheDatabase();
}
Also used : FunctionalTestHelper(org.neo4j.server.helpers.FunctionalTestHelper) BeforeClass(org.junit.BeforeClass)

Example 2 with FunctionalTestHelper

use of org.neo4j.server.helpers.FunctionalTestHelper in project neo4j by neo4j.

the class CompactJsonIT method setupServer.

@BeforeClass
public static void setupServer() throws IOException {
    functionalTestHelper = new FunctionalTestHelper(server());
    helper = functionalTestHelper.getGraphDbHelper();
}
Also used : FunctionalTestHelper(org.neo4j.server.helpers.FunctionalTestHelper) BeforeClass(org.junit.BeforeClass)

Example 3 with FunctionalTestHelper

use of org.neo4j.server.helpers.FunctionalTestHelper in project neo4j by neo4j.

the class HTTPLoggingIT method givenExplicitlyEnabledServerLoggingConfigurationShouldLogAccess.

@Test
public void givenExplicitlyEnabledServerLoggingConfigurationShouldLogAccess() throws Exception {
    // given
    String directoryPrefix = testName.getMethodName();
    File logDirectory = testDirectory.directory(directoryPrefix + "-logdir");
    final String query = "?explicitlyEnabled=" + randomString();
    NeoServer server = CommunityServerBuilder.server().withDefaultDatabaseTuning().persistent().withProperty(ServerSettings.http_logging_enabled.name(), Settings.TRUE).withProperty(GraphDatabaseSettings.logs_directory.name(), logDirectory.getAbsolutePath()).usingDataDir(testDirectory.directory(directoryPrefix + "-dbdir").getAbsolutePath()).build();
    try {
        server.start();
        FunctionalTestHelper functionalTestHelper = new FunctionalTestHelper(server);
        // when
        JaxRsResponse response = new RestRequest().get(functionalTestHelper.managementUri() + query);
        assertThat(response.getStatus(), is(HttpStatus.SC_OK));
        response.close();
        // then
        File httpLog = new File(logDirectory, "http.log");
        assertEventually("request appears in log", fileContentSupplier(httpLog), containsString(query), 5, TimeUnit.SECONDS);
    } finally {
        server.stop();
    }
}
Also used : NeoServer(org.neo4j.server.NeoServer) RestRequest(org.neo4j.server.rest.RestRequest) FunctionalTestHelper(org.neo4j.server.helpers.FunctionalTestHelper) Matchers.containsString(org.hamcrest.Matchers.containsString) JaxRsResponse(org.neo4j.server.rest.JaxRsResponse) FileUtils.readTextFile(org.neo4j.io.fs.FileUtils.readTextFile) File(java.io.File) Test(org.junit.Test)

Example 4 with FunctionalTestHelper

use of org.neo4j.server.helpers.FunctionalTestHelper 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 + "\""));
}
Also used : FunctionalTestHelper(org.neo4j.server.helpers.FunctionalTestHelper) JaxRsResponse(org.neo4j.server.rest.JaxRsResponse) Documented(org.neo4j.kernel.impl.annotations.Documented) Test(org.junit.Test) Title(org.neo4j.test.TestData.Title)

Example 5 with FunctionalTestHelper

use of org.neo4j.server.helpers.FunctionalTestHelper in project neo4j by neo4j.

the class EnterpriseVersionIT method setupServer.

@BeforeClass
public static void setupServer() throws Exception {
    FakeClock clock = Clocks.fakeClock();
    server = EnterpriseServerBuilder.server().usingDataDir(staticFolder.getRoot().getAbsolutePath()).withClock(clock).build();
    suppressAll().call((Callable<Void>) () -> {
        server.start();
        return null;
    });
    functionalTestHelper = new FunctionalTestHelper(server);
}
Also used : FakeClock(org.neo4j.time.FakeClock) FunctionalTestHelper(org.neo4j.server.helpers.FunctionalTestHelper) BeforeClass(org.junit.BeforeClass)

Aggregations

FunctionalTestHelper (org.neo4j.server.helpers.FunctionalTestHelper)30 BeforeClass (org.junit.BeforeClass)15 Test (org.junit.Test)15 JaxRsResponse (org.neo4j.server.rest.JaxRsResponse)13 Matchers.containsString (org.hamcrest.Matchers.containsString)4 Documented (org.neo4j.kernel.impl.annotations.Documented)3 RestRequest (org.neo4j.server.rest.RestRequest)3 Title (org.neo4j.test.TestData.Title)3 File (java.io.File)2 FileUtils.readTextFile (org.neo4j.io.fs.FileUtils.readTextFile)2 NeoServer (org.neo4j.server.NeoServer)2 CommunityServerBuilder (org.neo4j.server.helpers.CommunityServerBuilder)1 FakeClock (org.neo4j.time.FakeClock)1