Ejemplo n.º 1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldBeAbleToStartInHAMode() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldBeAbleToStartInHAMode()
        {
            // Given
            int       clusterPort = PortAuthority.allocatePort();
            NeoServer server      = EnterpriseServerBuilder.serverOnRandomPorts().usingDataDir(Folder.Root.AbsolutePath).withProperty(mode.name(), "HA").withProperty(server_id.name(), "1").withProperty(cluster_server.name(), ":" + clusterPort).withProperty(initial_hosts.name(), ":" + clusterPort).persistent().build();

            try
            {
                server.Start();
                server.Database;

                assertThat(server.Database.Graph, @is(instanceOf(typeof(HighlyAvailableGraphDatabase))));

                HTTP.Response haEndpoint = HTTP.GET(GetHaEndpoint(server));
                assertEquals(200, haEndpoint.Status());
                assertThat(haEndpoint.RawContent(), containsString("master"));

                HTTP.Response discovery = HTTP.GET(server.BaseUri().toASCIIString());
                assertEquals(200, discovery.Status());
            }
            finally
            {
                server.Stop();
            }
        }
Ejemplo n.º 2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldAllowAllAccessIfAuthenticationIsDisabled() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldAllowAllAccessIfAuthenticationIsDisabled()
        {
            // Given
            StartServer(false);

            // When & then
            assertEquals(201, HTTP.POST(Server.baseUri().resolve("db/data/node").ToString(), HTTP.RawPayload.quotedJson("{'name':'jake'}")).status());
            assertEquals(404, HTTP.GET(Server.baseUri().resolve("db/data/node/1234").ToString()).status());
            assertEquals(200, HTTP.POST(Server.baseUri().resolve("db/data/transaction/commit").ToString(), HTTP.RawPayload.quotedJson("{'statements':[{'statement':'MATCH (n) RETURN n'}]}")).status());
        }
Ejemplo n.º 3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldReturnEmptyMapForEmptyProperties()
        public virtual void ShouldReturnEmptyMapForEmptyProperties()
        {
            // Given
            string location = HTTP.POST(Server().baseUri().resolve("db/data/node").ToString()).location();

            // When
            HTTP.Response res = HTTP.GET(location + "/properties");

            // Then
            assertThat(res.RawContent(), equalTo("{ }"));
        }
Ejemplo n.º 4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testPropertyExistenceConstraintCanBeCreated()
        public virtual void TestPropertyExistenceConstraintCanBeCreated()
        {
            // Given running enterprise server
            string createConstraintUri = Neo4j.httpURI().resolve("test/myExtension/createConstraint").ToString();

            // When I run this server

            // Then constraint should be created
            HTTP.Response response = HTTP.GET(createConstraintUri);
            assertThat(response.Status(), equalTo(HttpStatus.CREATED_201));
        }
Ejemplo n.º 5
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldExtensionWork()
        public virtual void ShouldExtensionWork()
        {
            // Given running enterprise server
            string doSomethingUri = Neo4j.httpURI().resolve("test/myExtension/doSomething").ToString();

            // When I run this test

            // Then
            HTTP.Response response = HTTP.GET(doSomethingUri);
            assertThat(response.Status(), equalTo(234));
        }
Ejemplo n.º 6
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldAllowDataAccess() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldAllowDataAccess()
        {
            // Given
            StartServerWithConfiguredUser();

            // When & then
            AssertAuthorizationRequired("POST", "db/data/node", HTTP.RawPayload.quotedJson("{'name':'jake'}"), 201);
            AssertAuthorizationRequired("GET", "db/data/node/1234", 404);
            AssertAuthorizationRequired("POST", "db/data/transaction/commit", HTTP.RawPayload.quotedJson("{'statements':[{'statement':'MATCH (n) RETURN n'}]}"), 200);

            assertEquals(200, HTTP.GET(Server.baseUri().resolve("").ToString()).status());
        }
Ejemplo n.º 7
0
//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));
        }
Ejemplo n.º 8
0
//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));
        }
Ejemplo n.º 9
0
//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));
        }
Ejemplo n.º 10
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldReportEnterpriseEdition() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldReportEnterpriseEdition()
        {
            // Given
            string releaseVersion = Server.Database.Graph.DependencyResolver.resolveDependency(typeof(KernelData)).version().ReleaseVersion;

            // When
            HTTP.Response res = HTTP.GET(FunctionalTestHelper.managementUri() + "/" + VersionAndEditionService.SERVER_PATH);

            // Then
            assertEquals(200, res.Status());
            assertThat(res.Get("edition").asText(), equalTo("enterprise"));
            assertThat(res.Get("version").asText(), equalTo(releaseVersion));
        }
Ejemplo n.º 11
0
//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));
        }
Ejemplo n.º 12
0
        /*
         * 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());
        }
Ejemplo n.º 13
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldLaunchAServerInSpecifiedDirectory()
        public virtual void ShouldLaunchAServerInSpecifiedDirectory()
        {
            // Given
            File workDir = new File(TestDir.directory(), "specific");

            workDir.mkdir();

            // When
            using (ServerControls server = GetTestServerBuilder(workDir).newServer())
            {
                // Then
                assertThat(HTTP.GET(server.HttpURI().ToString()).status(), equalTo(200));
                assertThat(workDir.list().length, equalTo(1));
            }

            // And after it's been closed, it should've cleaned up after itself.
            assertThat(Arrays.ToString(workDir.list()), workDir.list().length, equalTo(0));
        }