//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private void startServer(boolean httpEnabled, boolean httpsEnabled) throws Exception private void StartServer(bool httpEnabled, bool httpsEnabled) { CommunityServerBuilder serverBuilder = serverOnRandomPorts().usingDataDir(Folder.directory(Name.MethodName).AbsolutePath); if (!httpEnabled) { serverBuilder.WithHttpDisabled(); } if (httpsEnabled) { serverBuilder.WithHttpsEnabled(); } _server = serverBuilder.Build(); _server.start(); // Because we are generating a non-CA-signed certificate, we need to turn off verification in the client. // This is ironic, since there is no proper verification on the CA side in the first place, but I digress. TrustManager[] trustAllCerts = new TrustManager[] { new InsecureTrustManager() }; // Install the all-trusting trust manager SSLContext sc = SSLContext.getInstance("TLS"); sc.init(null, trustAllCerts, new SecureRandom()); HttpsURLConnection.DefaultSSLSocketFactory = sc.SocketFactory; }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldMakeJAXRSClassesAvailableViaHTTP() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldMakeJAXRSClassesAvailableViaHTTP() { CommunityServerBuilder builder = CommunityServerBuilder.server(); _server = ServerHelper.createNonPersistentServer(builder); FunctionalTestHelper functionalTestHelper = new FunctionalTestHelper(_server); JaxRsResponse response = (new RestRequest()).get(functionalTestHelper.ManagementUri()); assertEquals(200, response.Status); response.Close(); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldNotWhitelistDB() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldNotWhitelistDB() { // 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)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldNotWhitelistConsoleService() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldNotWhitelistConsoleService() { // 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)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldWhitelistBrowser() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldWhitelistBrowser() { // 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)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void durationsAlwaysHaveUnitsInJMX() throws Throwable //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void DurationsAlwaysHaveUnitsInJMX() { // Given _server = CommunityServerBuilder.serverOnRandomPorts().withProperty(transaction_timeout.name(), "10").build(); // When _server.start(); // Then ObjectName name = getObjectName(_server.Database.Graph, ConfigurationBean.CONFIGURATION_MBEAN_NAME); string attr = getAttribute(name, transaction_timeout.name()); assertThat(attr, equalTo("10000ms")); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void serverConfigShouldBeVisibleInJMX() throws Throwable //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ServerConfigShouldBeVisibleInJMX() { // Given string configValue = TempDir.newFile().AbsolutePath; _server = CommunityServerBuilder.serverOnRandomPorts().withProperty(ServerSettings.run_directory.name(), configValue).build(); // When _server.start(); // Then ObjectName name = getObjectName(_server.Database.Graph, ConfigurationBean.CONFIGURATION_MBEAN_NAME); string attr = getAttribute(name, ServerSettings.run_directory.name()); assertThat(attr, equalTo(configValue)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldAllowDisablingAuthorization() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldAllowDisablingAuthorization() { // Given _server = CommunityServerBuilder.serverOnRandomPorts().withProperty(GraphDatabaseSettings.auth_enabled.name(), "false").build(); // When _server.start(); // Then I should have write access HTTP.Response response = HTTP.POST(_server.baseUri().resolve("db/data/node").ToString(), quotedJson("{'name':'My Node'}")); assertThat(response.Status(), equalTo(201)); string node = response.Location(); // Then I should have read access assertThat(HTTP.GET(node).status(), equalTo(200)); }
/* * The default jetty behaviour serves an index page for static resources. The 'directories' exposed through this * behaviour are not file system directories, but only a list of resources present on the classpath, so there is no * security vulnerability. However, it might seem like a vulnerability to somebody without the context of how the * whole stack works, so to avoid confusion we disable the jetty behaviour. */ //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldDisallowDirectoryListings() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldDisallowDirectoryListings() { // Given _server = CommunityServerBuilder.serverOnRandomPorts().build(); _server.start(); // When HTTP.Response okResource = HTTP.GET(_server.baseUri().resolve("/browser/index.html").ToString()); HTTP.Response illegalResource = HTTP.GET(_server.baseUri().resolve("/browser/assets/").ToString()); // Then // Depends on specific resources exposed by the browser module; if this test starts to fail, // check whether the structure of the browser module has changed and adjust accordingly. assertEquals(200, okResource.Status()); assertEquals(403, illegalResource.Status()); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldLoadThirdPartyJaxRsClasses() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldLoadThirdPartyJaxRsClasses() { _server = CommunityServerBuilder.serverOnRandomPorts().withThirdPartyJaxRsPackage("org.dummy.web.service", DummyThirdPartyWebService.DUMMY_WEB_SERVICE_MOUNT_POINT).usingDataDir(Folder.directory(Name.MethodName).AbsolutePath).build(); _server.start(); URI thirdPartyServiceUri = (new URI(_server.baseUri().ToString() + DummyThirdPartyWebService.DUMMY_WEB_SERVICE_MOUNT_POINT)).normalize(); string response = CLIENT.resource(thirdPartyServiceUri.ToString()).get(typeof(string)); assertEquals("hello", response); // Assert that extensions gets initialized int nodesCreated = CreateSimpleDatabase(_server.Database.Graph); thirdPartyServiceUri = (new URI(_server.baseUri().ToString() + DummyThirdPartyWebService.DUMMY_WEB_SERVICE_MOUNT_POINT + "/inject-test")).normalize(); response = CLIENT.resource(thirdPartyServiceUri.ToString()).get(typeof(string)); assertEquals(nodesCreated.ToString(), response); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldComplainIfServerPortIsAlreadyTaken() throws java.io.IOException //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldComplainIfServerPortIsAlreadyTaken() { using (ServerSocket socket = new ServerSocket(0, 0, InetAddress.LocalHost)) { ListenSocketAddress contestedAddress = new ListenSocketAddress(socket.InetAddress.HostName, socket.LocalPort); AssertableLogProvider logProvider = new AssertableLogProvider(); CommunityNeoServer server = CommunityServerBuilder.server(logProvider).onAddress(contestedAddress).usingDataDir(Folder.directory(Name.MethodName).AbsolutePath).build(); try { server.Start(); fail("Should have reported failure to start"); } catch (ServerStartupException e) { assertThat(e.Message, containsString("Starting Neo4j failed")); } logProvider.AssertAtLeastOnce(AssertableLogProvider.inLog(containsString("CommunityNeoServer")).error("Failed to start Neo4j on %s: %s", contestedAddress, format("Address %s is already in use, cannot bind to it.", contestedAddress))); server.Stop(); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @BeforeClass public static void allocateServer() throws java.io.IOException //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public static void AllocateServer() { _server = CommunityServerBuilder.serverOnRandomPorts().usingDataDir(StaticFolder.Root.AbsolutePath).withAutoIndexingEnabledForNodes("foo", "bar").build(); _server.start(); _functionalTestHelper = new FunctionalTestHelper(_server); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: protected org.neo4j.server.NeoServer getNeoServer(String customPageSwapperName) throws java.io.IOException protected internal override NeoServer GetNeoServer(string customPageSwapperName) { CommunityServerBuilder builder = EnterpriseServerBuilder.serverOnRandomPorts().withProperty(GraphDatabaseSettings.pagecache_swapper.name(), customPageSwapperName); return(builder.Build()); }