private void startServer( String hstsValue ) throws Exception { server = buildServer( hstsValue ); server.start(); }
protected void startServer( boolean authEnabled ) throws IOException { server = CommunityServerBuilder.serverOnRandomPorts() .withProperty( GraphDatabaseSettings.auth_enabled.name(), Boolean.toString( authEnabled ) ) .build(); server.start(); }
public void startServer( boolean authEnabled ) throws IOException { server = CommunityServerBuilder.serverOnRandomPorts() .withProperty( GraphDatabaseSettings.auth_enabled.name(), Boolean.toString( authEnabled ) ) .build(); server.start(); }
@Test public void shouldNotWhitelistConsoleService() throws Exception { // Given server = CommunityServerBuilder.serverOnRandomPorts() .withProperty( GraphDatabaseSettings.auth_enabled.name(), "true" ).build(); // When server.start(); // Then I should be able to access the console service HTTP.Response response = HTTP.GET( server.baseUri().resolve( "db/manage/server/console" ).toString() ); assertThat( response.status(), equalTo( 401 ) ); }
protected void startServer( boolean authEnabled, String accessControlAllowOrigin ) throws IOException { server = CommunityServerBuilder.serverOnRandomPorts() .withProperty( GraphDatabaseSettings.auth_enabled.name(), Boolean.toString( authEnabled ) ) .withProperty( ServerSettings.http_access_control_allow_origin.name(), accessControlAllowOrigin ) .build(); server.start(); }
@BeforeClass public static void allocateServer() throws IOException { server = CommunityServerBuilder.serverOnRandomPorts() .usingDataDir( staticFolder.getRoot().getAbsolutePath() ) .withAutoIndexingEnabledForNodes( "foo", "bar" ) .build(); server.start(); functionalTestHelper = new FunctionalTestHelper( server ); }
@Test public void shouldGenerateWADLWhenExplicitlyEnabledInConfig() throws IOException { server = serverOnRandomPorts().withProperty( ServerSettings.wadl_enabled.name(), "true" ) .usingDataDir( folder.directory( name.getMethodName() ).getAbsolutePath() ) .build(); server.start(); JaxRsResponse response = new RestRequest().get( server.baseUri().toString() + "application.wadl", MediaType.WILDCARD_TYPE ); assertEquals( 200, response.getStatus() ); assertEquals( "application/vnd.sun.wadl+xml", response.getHeaders().get( "Content-Type" ).iterator().next() ); assertThat( response.getEntity(), containsString( "<application xmlns=\"http://wadl.dev.java" + ".net/2009/02\">" ) ); }
@Test public void shouldNotWhitelistDB() throws Exception { // Given server = CommunityServerBuilder.serverOnRandomPorts() .withProperty( GraphDatabaseSettings.auth_enabled.name(), "true" ).build(); // When server.start(); // Then I should get a unauthorized response for access to the DB HTTP.Response response = HTTP.GET(HTTP.GET( server.baseUri().resolve( "db/data" ).toString()).location() ); assertThat( response.status(), equalTo( 401 ) ); }
@Test public void serverShouldNotHangWithThreadPoolSizeSmallerThanCpuCount() throws Exception { server = serverOnRandomPorts().withMaxJettyThreads( 3 ) .usingDataDir( folder.directory( name.getMethodName() ).getAbsolutePath() ) .build(); server.start(); assertThat( GET(server.baseUri().toString()).status(), is( 200 ) ); } }
@Before public void setUp() throws Exception { server = serverOnRandomPorts().withProperty( GraphDatabaseSettings.snapshot_query.name(), Settings.TRUE ).build(); server.start(); }
@Test public void serverConfigShouldBeVisibleInJMX() throws Throwable { // Given String configValue = tempDir.newFile().getAbsolutePath(); server = CommunityServerBuilder.serverOnRandomPorts().withProperty( ServerSettings.run_directory.name(), configValue ).build(); // When server.start(); // Then ObjectName name = getObjectName( server.getDatabase().getGraph(), ConfigurationBean.CONFIGURATION_MBEAN_NAME ); String attr = getAttribute( name, ServerSettings.run_directory.name() ); assertThat( attr, equalTo( configValue ) ); }
@Test public void shouldWhitelistBrowser() throws Exception { // Given assumeTrue( browserIsLoaded() ); server = CommunityServerBuilder.serverOnRandomPorts() .withProperty( GraphDatabaseSettings.auth_enabled.name(), "true" ).build(); // When server.start(); // Then I should be able to access the browser HTTP.Response response = HTTP.GET( server.baseUri().resolve( "browser/index.html" ).toString() ); assertThat( response.status(), equalTo( 200 ) ); }
@Test public void shouldEnableConsoleServiceByDefault() throws IOException { // Given server = serverOnRandomPorts() .usingDataDir( folder.directory( name.getMethodName() ).getAbsolutePath() ) .build(); server.start(); // When & then assertEquals( 200, new RestRequest().get( server.baseUri().toString() + "db/manage/server/console" ).getStatus() ); }
@Test public void shouldNotGenerateWADLWhenNotExplicitlyEnabledInConfig() throws IOException { server = serverOnRandomPorts() .usingDataDir( folder.directory( name.getMethodName() ).getAbsolutePath() ) .build(); server.start(); JaxRsResponse response = new RestRequest().get( server.baseUri().toString() + "application.wadl", MediaType.WILDCARD_TYPE ); assertEquals( 404, response.getStatus() ); }
@Test public void shouldDisableConsoleServiceWhenAskedTo() throws IOException { // Given server = serverOnRandomPorts().withProperty( ServerSettings.console_module_enabled.name(), "false" ) .usingDataDir( folder.directory( name.getMethodName() ).getAbsolutePath() ) .build(); server.start(); // When & then assertEquals( 404, new RestRequest().get( server.baseUri().toString() + "db/manage/server/console" ).getStatus() ); }
@Test public void shouldNotGenerateWADLWhenExplicitlyDisabledInConfig() throws IOException { server = serverOnRandomPorts().withProperty( ServerSettings.wadl_enabled.name(), "false" ) .usingDataDir( folder.directory( name.getMethodName() ).getAbsolutePath() ) .build(); server.start(); JaxRsResponse response = new RestRequest().get( server.baseUri().toString() + "application.wadl", MediaType.WILDCARD_TYPE ); assertEquals( 404, response.getStatus() ); }
@Test public void shouldRespondWith201IfAllTheRulesPassWhenCreatingANode() throws Exception { server = CommunityServerBuilder.serverOnRandomPorts().withDefaultDatabaseTuning().withSecurityRules( PermanentlyPassingSecurityRule.class.getCanonicalName() ) .usingDataDir( folder.directory( name.getMethodName() ).getAbsolutePath() ) .build(); server.start(); functionalTestHelper = new FunctionalTestHelper( server ); gen.get().expectedStatus( 201 ).expectedHeader( "Location" ).post( functionalTestHelper.nodeUri() ).response(); }
@Test public void shouldPickUpAddressFromConfig() throws Exception { ListenSocketAddress nonDefaultAddress = new ListenSocketAddress( "0.0.0.0", 0 ); server = server().onAddress( nonDefaultAddress ) .usingDataDir( folder.directory( name.getMethodName() ).getAbsolutePath() ) .build(); server.start(); HostnamePort localHttpAddress = getLocalHttpAddress(); assertNotEquals( HttpConnector.Encryption.NONE.defaultPort, localHttpAddress.getPort() ); assertEquals( nonDefaultAddress.getHostname(), localHttpAddress.getHost() ); JaxRsResponse response = new RestRequest( server.baseUri() ).get(); assertThat( response.getStatus(), is( 200 ) ); response.close(); }
private void startServerWithBoltEnabled( String advertisedHost, int advertisedPort, String listenHost, int listenPort ) throws IOException { server = serverOnRandomPorts() .withProperty( new BoltConnector( "bolt" ).type.name(), "BOLT" ) .withProperty( new BoltConnector( "bolt" ).enabled.name(), "true" ) .withProperty( new BoltConnector( "bolt" ).encryption_level.name(), "REQUIRED" ) .withProperty( new BoltConnector( "bolt" ).advertised_address.name(), advertisedHost + ":" + advertisedPort ) .withProperty( new BoltConnector( "bolt" ).listen_address.name(), listenHost + ":" + listenPort ) .usingDataDir( tmpDir.getRoot().getAbsolutePath() ).build(); server.start(); }
@Test public void shouldLaunchBolt() throws Throwable { // When I run Neo4j with Bolt enabled server = serverOnRandomPorts().withProperty( new BoltConnector( "bolt" ).type.name(), "BOLT" ) .withProperty( new BoltConnector( "bolt" ).enabled.name(), "true" ) .withProperty( new BoltConnector( "bolt" ).encryption_level.name(), "REQUIRED" ) .withProperty( new BoltConnector( "bolt" ).listen_address.name(), "localhost:0" ) .usingDataDir( tmpDir.getRoot().getAbsolutePath() ).build(); server.start(); ConnectorPortRegister connectorPortRegister = getDependency( ConnectorPortRegister.class ); // Then assertEventuallyServerResponds( "localhost", connectorPortRegister.getLocalAddress( "bolt" ).getPort() ); }