//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldReportThirdPartyPackagesAtSpecifiedMount() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldReportThirdPartyPackagesAtSpecifiedMount() { // Given WebServer webServer = mock(typeof(WebServer)); CommunityNeoServer neoServer = mock(typeof(CommunityNeoServer)); when(neoServer.BaseUri()).thenReturn(new URI("http://localhost:7575")); when(neoServer.WebServer).thenReturn(webServer); Database database = mock(typeof(Database)); when(neoServer.Database).thenReturn(database); Config config = mock(typeof(Config)); IList <ThirdPartyJaxRsPackage> jaxRsPackages = new List <ThirdPartyJaxRsPackage>(); string path = "/third/party/package"; jaxRsPackages.Add(new ThirdPartyJaxRsPackage("org.example.neo4j", path)); when(config.Get(ServerSettings.third_party_packages)).thenReturn(jaxRsPackages); // When ThirdPartyJAXRSModule module = new ThirdPartyJAXRSModule(webServer, config, NullLogProvider.Instance, neoServer); module.Start(); // Then verify(webServer).addJAXRSPackages(any(typeof(System.Collections.IList)), anyString(), anyCollection()); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldRespondWith201IfAllTheRulesPassWhenCreatingANode() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldRespondWith201IfAllTheRulesPassWhenCreatingANode() { //JAVA TO C# CONVERTER WARNING: The .NET Type.FullName property will not always yield results identical to the Java Class.getCanonicalName method: _server = CommunityServerBuilder.serverOnRandomPorts().withDefaultDatabaseTuning().withSecurityRules(typeof(PermanentlyPassingSecurityRule).FullName).usingDataDir(Folder.directory(Name.MethodName).AbsolutePath).build(); _server.start(); _functionalTestHelper = new FunctionalTestHelper(_server); Gen.get().expectedStatus(201).expectedHeader("Location").post(_functionalTestHelper.nodeUri()).response(); }
public virtual void Should401WithBasicChallengeWhenASecurityRuleFails() { //JAVA TO C# CONVERTER WARNING: The .NET Type.FullName property will not always yield results identical to the Java Class.getCanonicalName method: _server = CommunityServerBuilder.serverOnRandomPorts().withDefaultDatabaseTuning().withSecurityRules(typeof(PermanentlyFailingSecurityRule).FullName).usingDataDir(Folder.directory(Name.MethodName).AbsolutePath).build(); _server.start(); _functionalTestHelper = new FunctionalTestHelper(_server); JaxRsResponse response = Gen.get().expectedStatus(401).expectedHeader("WWW-Authenticate").post(_functionalTestHelper.nodeUri()).response(); assertThat(response.Headers.getFirst("WWW-Authenticate"), containsString("Basic realm=\"" + PermanentlyFailingSecurityRule.REALM + "\"")); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void should403WhenAuthenticatedButForbidden() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void Should403WhenAuthenticatedButForbidden() { //JAVA TO C# CONVERTER WARNING: The .NET Type.FullName property will not always yield results identical to the Java Class.getCanonicalName method: _server = CommunityServerBuilder.serverOnRandomPorts().withDefaultDatabaseTuning().withSecurityRules(typeof(PermanentlyForbiddenSecurityRule).FullName, typeof(PermanentlyPassingSecurityRule).FullName).usingDataDir(Folder.directory(Name.MethodName).AbsolutePath).build(); _server.start(); _functionalTestHelper = new FunctionalTestHelper(_server); JaxRsResponse clientResponse = Gen.get().expectedStatus(403).expectedType(MediaType.APPLICATION_JSON_TYPE).get(TrimTrailingSlash(_functionalTestHelper.baseUri())).response(); assertEquals(403, clientResponse.Status); }
//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 shouldInvokeAllSecurityRules() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldInvokeAllSecurityRules() { // given //JAVA TO C# CONVERTER WARNING: The .NET Type.FullName property will not always yield results identical to the Java Class.getCanonicalName method: _server = CommunityServerBuilder.serverOnRandomPorts().withDefaultDatabaseTuning().withSecurityRules(typeof(NoAccessToDatabaseSecurityRule).FullName).usingDataDir(Folder.directory(Name.MethodName).AbsolutePath).build(); _server.start(); _functionalTestHelper = new FunctionalTestHelper(_server); // when Gen.get().expectedStatus(401).get(_functionalTestHelper.dataUri()).response(); // then assertTrue(NoAccessToDatabaseSecurityRule.WasInvoked()); }
public virtual void ASimpleWildcardUriPathShould401OnAccessToProtectedSubPath() { string mountPoint = "/protected/tree/starts/here" + DummyThirdPartyWebService.DUMMY_WEB_SERVICE_MOUNT_POINT; //JAVA TO C# CONVERTER WARNING: The .NET Type.FullName property will not always yield results identical to the Java Class.getCanonicalName method: _server = CommunityServerBuilder.serverOnRandomPorts().withDefaultDatabaseTuning().withThirdPartyJaxRsPackage("org.dummy.web.service", mountPoint).withSecurityRules(typeof(PermanentlyFailingSecurityRuleWithWildcardPath).FullName).usingDataDir(Folder.directory(Name.MethodName).AbsolutePath).build(); _server.start(); _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.Status); }
//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 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 shouldRegisterASingleUri() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldRegisterASingleUri() { WebServer webServer = mock(typeof(WebServer)); CommunityNeoServer neoServer = mock(typeof(CommunityNeoServer)); when(neoServer.BaseUri()).thenReturn(new URI("http://localhost:7575")); when(neoServer.WebServer).thenReturn(webServer); IDictionary <string, string> @params = new Dictionary <string, string>(); string managementPath = "/db/manage"; @params[ServerSettings.management_api_path.name()] = managementPath; Config config = Config.defaults(@params); when(neoServer.Config).thenReturn(config); ManagementApiModule module = new ManagementApiModule(webServer, config); module.Start(); verify(webServer).addJAXRSClasses(anyListOf(typeof(string)), anyString(), any()); }
//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 TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Before public void setUp() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void SetUp() { _server = serverOnRandomPorts().withProperty(GraphDatabaseSettings.snapshot_query.name(), Settings.TRUE).build(); _server.start(); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: public void startServer(boolean authEnabled) throws java.io.IOException public virtual void StartServer(bool authEnabled) { _server = CommunityServerBuilder.serverOnRandomPorts().withProperty(GraphDatabaseSettings.auth_enabled.name(), Convert.ToString(authEnabled)).build(); _server.start(); }