Search in sources :

Example 6 with NeoServer

use of org.neo4j.server.NeoServer in project neo4j by neo4j.

the class HTTPLoggingIT method givenExplicitlyDisabledServerLoggingConfigurationShouldNotLogAccesses.

@Test
public void givenExplicitlyDisabledServerLoggingConfigurationShouldNotLogAccesses() throws Exception {
    // given
    String directoryPrefix = testName.getMethodName();
    File logDirectory = testDirectory.directory(directoryPrefix + "-logdir");
    NeoServer server = CommunityServerBuilder.server().withDefaultDatabaseTuning().persistent().withProperty(ServerSettings.http_logging_enabled.name(), Settings.FALSE).withProperty(GraphDatabaseSettings.logs_directory.name(), logDirectory.toString()).usingDataDir(testDirectory.directory(directoryPrefix + "-dbdir").getAbsolutePath()).build();
    try {
        server.start();
        FunctionalTestHelper functionalTestHelper = new FunctionalTestHelper(server);
        // when
        String query = "?implicitlyDisabled" + randomString();
        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");
        assertThat(httpLog.exists(), is(false));
    } 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 7 with NeoServer

use of org.neo4j.server.NeoServer in project neo4j by neo4j.

the class EnterpriseServerIT method shouldRequireAuthorizationForHAStatusEndpoints.

@Test
public void shouldRequireAuthorizationForHAStatusEndpoints() throws Exception {
    // Given
    NeoServer server = EnterpriseServerBuilder.server().withProperty(GraphDatabaseSettings.auth_enabled.name(), "true").usingDataDir(folder.getRoot().getAbsolutePath()).withProperty(mode.name(), "HA").withProperty(server_id.name(), "1").withProperty(initial_hosts.name(), ":5001").persistent().build();
    try {
        server.start();
        server.getDatabase();
        assertThat(server.getDatabase().getGraph(), is(instanceOf(HighlyAvailableGraphDatabase.class)));
        Client client = Client.create();
        ClientResponse r = client.resource("http://localhost:7474/db/manage/server/ha").accept(APPLICATION_JSON).get(ClientResponse.class);
        assertEquals(401, r.getStatus());
    } finally {
        server.stop();
    }
}
Also used : NeoServer(org.neo4j.server.NeoServer) ClientResponse(com.sun.jersey.api.client.ClientResponse) Client(com.sun.jersey.api.client.Client) Test(org.junit.Test)

Example 8 with NeoServer

use of org.neo4j.server.NeoServer in project neo4j by neo4j.

the class EnterpriseServerIT method shouldAllowDisablingAuthorizationOnHAStatusEndpoints.

@Test
public void shouldAllowDisablingAuthorizationOnHAStatusEndpoints() throws Exception {
    // Given
    NeoServer server = EnterpriseServerBuilder.server().withProperty(GraphDatabaseSettings.auth_enabled.name(), "true").withProperty(HaSettings.ha_status_auth_enabled.name(), "false").usingDataDir(folder.getRoot().getAbsolutePath()).withProperty(mode.name(), "HA").withProperty(server_id.name(), "1").withProperty(initial_hosts.name(), ":5001").persistent().build();
    try {
        server.start();
        server.getDatabase();
        assertThat(server.getDatabase().getGraph(), is(instanceOf(HighlyAvailableGraphDatabase.class)));
        Client client = Client.create();
        ClientResponse r = client.resource("http://localhost:7474/db/manage/server/ha").accept(APPLICATION_JSON).get(ClientResponse.class);
        assertEquals(200, r.getStatus());
        assertThat(r.getEntity(String.class), containsString("master"));
    } finally {
        server.stop();
    }
}
Also used : NeoServer(org.neo4j.server.NeoServer) ClientResponse(com.sun.jersey.api.client.ClientResponse) Matchers.containsString(org.hamcrest.Matchers.containsString) Client(com.sun.jersey.api.client.Client) Test(org.junit.Test)

Example 9 with NeoServer

use of org.neo4j.server.NeoServer in project neo4j by neo4j.

the class ServerHelper method createServer.

private static NeoServer createServer(CommunityServerBuilder builder, boolean persistent, File path) throws IOException {
    if (persistent) {
        builder = builder.persistent();
    }
    NeoServer server = builder.usingDataDir(path != null ? path.getAbsolutePath() : null).build();
    checkServerCanStart(server.baseUri().getHost(), server.baseUri().getPort());
    server.start();
    return server;
}
Also used : NeoServer(org.neo4j.server.NeoServer)

Example 10 with NeoServer

use of org.neo4j.server.NeoServer in project neo4j by neo4j.

the class ExtensionInitializerTest method testPluginInitialization.

@Test
public void testPluginInitialization() {
    Config config = Config.embeddedDefaults(stringMap(ServerSettings.transaction_idle_timeout.name(), "600"));
    NeoServer neoServer = Mockito.mock(NeoServer.class, Mockito.RETURNS_DEEP_STUBS);
    Mockito.when(neoServer.getConfig()).thenReturn(config);
    ExtensionInitializer extensionInitializer = new ExtensionInitializer(neoServer);
    Collection<Injectable<?>> injectableProperties = extensionInitializer.initializePackages(Arrays.asList("org.neo4j.server.modules"));
    assertTrue(injectableProperties.stream().anyMatch(i -> ServerSettings.transaction_idle_timeout.name().equals(i.getValue())));
}
Also used : NeoServer(org.neo4j.server.NeoServer) Configuration(org.apache.commons.configuration.Configuration) Arrays(java.util.Arrays) Config(org.neo4j.kernel.configuration.Config) Collection(java.util.Collection) ServerSettings(org.neo4j.server.configuration.ServerSettings) Iterators(org.neo4j.helpers.collection.Iterators) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) Function(java.util.function.Function) NeoServer(org.neo4j.server.NeoServer) Mockito(org.mockito.Mockito) Injectable(org.neo4j.server.plugins.Injectable) GraphDatabaseService(org.neo4j.graphdb.GraphDatabaseService) PluginLifecycle(org.neo4j.server.plugins.PluginLifecycle) MapUtil.stringMap(org.neo4j.helpers.collection.MapUtil.stringMap) Injectable(org.neo4j.server.plugins.Injectable) Config(org.neo4j.kernel.configuration.Config) Test(org.junit.Test)

Aggregations

NeoServer (org.neo4j.server.NeoServer)13 Test (org.junit.Test)10 File (java.io.File)6 Matchers.containsString (org.hamcrest.Matchers.containsString)6 ClientResponse (com.sun.jersey.api.client.ClientResponse)4 FileUtils.readTextFile (org.neo4j.io.fs.FileUtils.readTextFile)4 Client (com.sun.jersey.api.client.Client)3 FunctionalTestHelper (org.neo4j.doc.server.helpers.FunctionalTestHelper)2 JaxRsResponse (org.neo4j.doc.server.rest.JaxRsResponse)2 RestRequest (org.neo4j.doc.server.rest.RestRequest)2 Config (org.neo4j.kernel.configuration.Config)2 FunctionalTestHelper (org.neo4j.server.helpers.FunctionalTestHelper)2 JaxRsResponse (org.neo4j.server.rest.JaxRsResponse)2 RestRequest (org.neo4j.server.rest.RestRequest)2 Arrays (java.util.Arrays)1 Collection (java.util.Collection)1 Function (java.util.function.Function)1 Configuration (org.apache.commons.configuration.Configuration)1 Assert.assertTrue (org.junit.Assert.assertTrue)1 Mockito (org.mockito.Mockito)1