Example #1
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private void assertAuthorizationRequired(String method, String path, Object payload, int expectedAuthorizedStatus) throws org.neo4j.server.rest.domain.JsonParseException
        private void AssertAuthorizationRequired(string method, string path, object payload, int expectedAuthorizedStatus)
        {
            // When no header
            HTTP.Response response = HTTP.request(method, Server.baseUri().resolve(path).ToString(), payload);
            assertThat(response.Status(), equalTo(401));
            assertThat(response.Get("errors").get(0).get("code").asText(), equalTo("Neo.ClientError.Security.Unauthorized"));
            assertThat(response.Get("errors").get(0).get("message").asText(), equalTo("No authentication header supplied."));
            assertThat(response.Header(HttpHeaders.WWW_AUTHENTICATE), equalTo("Basic realm=\"Neo4j\""));

            // When malformed header
            response = HTTP.withHeaders(HttpHeaders.AUTHORIZATION, "This makes no sense").request(method, Server.baseUri().resolve(path).ToString(), payload);
            assertThat(response.Status(), equalTo(400));
            assertThat(response.Get("errors").get(0).get("code").asText(), equalTo("Neo.ClientError.Request.InvalidFormat"));
            assertThat(response.Get("errors").get(0).get("message").asText(), equalTo("Invalid authentication header."));

            // When invalid credential
            response = HTTP.withBasicAuth("neo4j", "incorrect").request(method, Server.baseUri().resolve(path).ToString(), payload);
            assertThat(response.Status(), equalTo(401));
            assertThat(response.Get("errors").get(0).get("code").asText(), equalTo("Neo.ClientError.Security.Unauthorized"));
            assertThat(response.Get("errors").get(0).get("message").asText(), equalTo("Invalid username or password."));
            assertThat(response.Header(HttpHeaders.WWW_AUTHENTICATE), equalTo("Basic realm=\"Neo4j\""));

            // When authorized
            response = HTTP.withBasicAuth("neo4j", "secret").request(method, Server.baseUri().resolve(path).ToString(), payload);
            assertThat(response.Status(), equalTo(expectedAuthorizedStatus));
        }
Example #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldReplyNicelyToTooManyFailedAuthAttempts() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldReplyNicelyToTooManyFailedAuthAttempts()
        {
            // Given
            StartServerWithConfiguredUser();
            long timeout = DateTimeHelper.CurrentUnixTimeMillis() + 30_000;

            // When
            HTTP.Response response = null;
            while (DateTimeHelper.CurrentUnixTimeMillis() < timeout)
            {
                // Done in a loop because we're racing with the clock to get enough failed requests into 5 seconds
                response = HTTP.withBasicAuth("neo4j", "incorrect").POST(Server.baseUri().resolve("authentication").ToString(), HTTP.RawPayload.quotedJson("{'username':'******', 'password':'******'}"));

                if (response.Status() == 429)
                {
                    break;
                }
            }

            // Then
            assertThat(response.Status(), equalTo(429));
            JsonNode firstError = response.Get("errors").get(0);

            assertThat(firstError.get("code").asText(), equalTo("Neo.ClientError.Security.AuthenticationRateLimit"));
            assertThat(firstError.get("message").asText(), equalTo("Too many failed authentication requests. Please wait 5 seconds and try again."));
        }
Example #3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldHandleArrayOfPointsUsingGraphResultDataContent() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldHandleArrayOfPointsUsingGraphResultDataContent()
        {
            //Given
            GraphDatabaseFacade db = Server().Database.Graph;

            using (Transaction tx = Db.beginTx())
            {
                Node node = Db.createNode(label("N"));
                node.SetProperty("coordinates", new Point[] { pointValue(WGS84, 30.655691, 104.081602) });
                tx.Success();
            }

            //When
            HTTP.Response response = RunQuery("MATCH (n:N) RETURN n", "graph");

            assertEquals(200, response.Status());
            AssertNoErrors(response);

            //Then
            JsonNode row = response.Get("results").get(0).get("data").get(0).get("graph").get("nodes").get(0).get("properties").get("coordinates").get(0);

            AssertGeometryTypeEqual(GeometryType.GEOMETRY_POINT, row);
            AssertCoordinatesEqual(new double[] { 30.655691, 104.081602 }, row);
            AssertCrsEqual(WGS84, row);
        }
Example #4
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();
            }
        }
Example #5
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldWorkWithPoint2DArrays() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldWorkWithPoint2DArrays()
        {
            HTTP.Response response = RunQuery("create (:Node {points: [point({x:1, y:1}), point({x:2, y:2}), point({x: 3.0, y: 3.0})]})");

            assertEquals(200, response.Status());
            AssertNoErrors(response);

            GraphDatabaseFacade db = Server().Database.Graph;

            using (Transaction tx = Db.beginTx())
            {
                foreach (Node node in Db.AllNodes)
                {
                    if (node.HasLabel(label("Node")) && node.HasProperty("points"))
                    {
                        Point[] points = ( Point[] )node.GetProperty("points");

                        VerifyPoint(points[0], Cartesian, 1.0, 1.0);
                        VerifyPoint(points[1], Cartesian, 2.0, 2.0);
                        VerifyPoint(points[2], Cartesian, 3.0, 3.0);
                    }
                }
                tx.Success();
            }
        }
Example #6
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public void startServerWithConfiguredUser() throws java.io.IOException
        public virtual void StartServerWithConfiguredUser()
        {
            StartServer(true);
            // Set the password
            HTTP.Response post = HTTP.withBasicAuth("neo4j", "neo4j").POST(Server.baseUri().resolve("/user/neo4j/password").ToString(), HTTP.RawPayload.quotedJson("{'password':'******'}"));
            assertEquals(200, post.Status());
        }
Example #7
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private void testCorsAllowMethods(org.neo4j.server.web.HttpMethod method, String origin) throws Exception
        private void TestCorsAllowMethods(HttpMethod method, string origin)
        {
            HTTP.Builder  requestBuilder = RequestWithHeaders("authDisabled", "authDisabled").withHeaders(ACCESS_CONTROL_REQUEST_METHOD, method.ToString());
            HTTP.Response response       = RunQuery(requestBuilder);

            assertEquals(OK.StatusCode, response.Status());
            AssertCorsHeaderEquals(response, origin);
            assertEquals(method, HttpMethod.valueOf(response.Header(ACCESS_CONTROL_ALLOW_METHODS)));
        }
Example #8
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldAddCorsHeaderWhenAuthEnabledAndPasswordChangeRequired() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldAddCorsHeaderWhenAuthEnabledAndPasswordChangeRequired()
        {
            StartServer(true);

            HTTP.Response response = RunQuery("neo4j", "neo4j");

            assertEquals(FORBIDDEN.StatusCode, response.Status());
            AssertCorsHeaderPresent(response);
            assertThat(response.Content().ToString(), containsString("password_change"));
        }
Example #9
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldAddCorsHeaderWhenAuthDisabled() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldAddCorsHeaderWhenAuthDisabled()
        {
            StartServer(false);

            HTTP.Response response = RunQuery("authDisabled", "authDisabled");

            assertEquals(OK.StatusCode, response.Status());
            AssertCorsHeaderPresent(response);
            assertThat(response.Content().ToString(), containsString("42"));
        }
Example #10
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldWorkWithTime() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldWorkWithTime()
        {
            HTTP.Response response = RunQuery("RETURN time({hour: 23, minute: 19, second: 55, timezone:\\\"-07:00\\\"})");

            assertEquals(200, response.Status());
            AssertNoErrors(response);
            JsonNode data = GetSingleData(response);

            AssertTemporalEquals(data, "23:19:55-07:00", "time");
        }
Example #11
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldWorkWithDate() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldWorkWithDate()
        {
            HTTP.Response response = RunQuery("RETURN date({year: 1984, month: 10, day: 11})");

            assertEquals(200, response.Status());
            AssertNoErrors(response);
            JsonNode data = GetSingleData(response);

            AssertTemporalEquals(data, "1984-10-11", "date");
        }
Example #12
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldWorkWithLocalTime() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldWorkWithLocalTime()
        {
            HTTP.Response response = RunQuery("RETURN localtime({hour:12, minute:31, second:14, nanosecond: 645876123})");

            assertEquals(200, response.Status());
            AssertNoErrors(response);
            JsonNode data = GetSingleData(response);

            AssertTemporalEquals(data, "12:31:14.645876123", "localtime");
        }
Example #13
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldAddCorsHeaderWhenAuthEnabledAndIncorrectPassword() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldAddCorsHeaderWhenAuthEnabledAndIncorrectPassword()
        {
            StartServer(true);

            HTTP.Response response = RunQuery("neo4j", "wrongPassword");

            assertEquals(UNAUTHORIZED.StatusCode, response.Status());
            AssertCorsHeaderPresent(response);
            assertThat(response.Content().ToString(), containsString("Neo.ClientError.Security.Unauthorized"));
        }
Example #14
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldWorkWithLocalDateTime() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldWorkWithLocalDateTime()
        {
            HTTP.Response response = RunQuery("RETURN localdatetime({year: 1984, month: 10, day: 21, hour: 12, minute: 34})");

            assertEquals(200, response.Status());
            AssertNoErrors(response);
            JsonNode data = GetSingleData(response);

            AssertTemporalEquals(data, "1984-10-21T12:34", "localdatetime");
        }
Example #15
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldWorkWithDateTime() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldWorkWithDateTime()
        {
            HTTP.Response response = RunQuery("RETURN datetime({year: 1, month:10, day:2, timezone:\\\"+01:00\\\"})");

            assertEquals(200, response.Status());
            AssertNoErrors(response);
            JsonNode data = GetSingleData(response);

            AssertTemporalEquals(data, "0001-10-02T00:00+01:00", "datetime");
        }
Example #16
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldWorkWithDuration() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldWorkWithDuration()
        {
            HTTP.Response response = RunQuery("RETURN duration({weeks:2, days:3})");

            assertEquals(200, response.Status());
            AssertNoErrors(response);
            JsonNode data = GetSingleData(response);

            AssertTemporalEquals(data, "P17D", "duration");
        }
Example #17
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));
        }
Example #18
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldAddCorsRequestHeaders() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldAddCorsRequestHeaders()
        {
            StartServer(false);

            HTTP.Builder  requestBuilder = RequestWithHeaders("authDisabled", "authDisabled").withHeaders(ACCESS_CONTROL_REQUEST_HEADERS, "Accept, X-Not-Accept");
            HTTP.Response response       = RunQuery(requestBuilder);

            assertEquals(OK.StatusCode, response.Status());
            AssertCorsHeaderPresent(response);
            assertEquals("Accept, X-Not-Accept", response.Header(ACCESS_CONTROL_ALLOW_HEADERS));
        }
Example #19
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));
        }
Example #20
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));
        }
Example #21
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void runningInCompiledRuntime()
        public virtual void RunningInCompiledRuntime()
        {
            // Given
            string uri     = FunctionalTestHelper.dataUri() + "transaction/commit";
            string payload = "{ 'statements': [ { 'statement': 'CYPHER runtime=compiled MATCH (n) RETURN n' } ] }";

            // When
            HTTP.Response res = HTTP.POST(uri, payload.replaceAll("'", "\""));

            // Then
            assertEquals(200, res.Status());
        }
Example #22
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));
        }
Example #23
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test(timeout = 60000) public void deadlockShouldRollbackTransaction() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void DeadlockShouldRollbackTransaction()
        {
            // Given
            HTTP.Response initial = POST(TxCommitUri(), quotedJson("{'statements': [{'statement': 'CREATE (n1 {prop : 1}), (n2 {prop : 2})'}]}"));
            assertThat(initial.Status(), @is(200));
            assertThat(initial, containsNoErrors());

            // When

            // tx1 takes a write lock on node1
            HTTP.Response firstInTx1 = POST(TxUri(), quotedJson("{'statements': [{'statement': 'MATCH (n {prop : 1}) SET n.prop = 3'}]}"));
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final long tx1 = extractTxId(firstInTx1);
            long tx1 = ExtractTxId(firstInTx1);

            // tx2 takes a write lock on node2
            HTTP.Response firstInTx2 = POST(TxUri(), quotedJson("{'statements': [{'statement': 'MATCH (n {prop : 2}) SET n.prop = 4'}]}"));
            long          tx2        = ExtractTxId(firstInTx2);

            // tx1 attempts to take a write lock on node2
            Future <HTTP.Response> future = OtherThread.execute(state => POST(TxUri(tx1), quotedJson("{'statements': [{'statement': 'MATCH (n {prop : 2}) SET n.prop = 5'}]}")));

            // tx2 attempts to take a write lock on node1
            HTTP.Response secondInTx2 = POST(TxUri(tx2), quotedJson("{'statements': [{'statement': 'MATCH (n {prop : 1}) SET n.prop = 6'}]}"));

            HTTP.Response secondInTx1 = future.get();

            // Then
            assertThat(secondInTx1.Status(), @is(200));
            assertThat(secondInTx2.Status(), @is(200));

            // either tx1 or tx2 should fail because of the deadlock
            HTTP.Response failed;
            if (ContainsError(secondInTx1))
            {
                failed = secondInTx1;
            }
            else if (ContainsError(secondInTx2))
            {
                failed = secondInTx2;
            }
            else
            {
                failed = null;
                fail("Either tx1 or tx2 is expected to fail");
            }

            assertThat(failed, hasErrors(Org.Neo4j.Kernel.Api.Exceptions.Status_Transaction.DeadlockDetected));

            // transaction was rolled back on the previous step and we can't commit it
            HTTP.Response commit = POST(failed.StringFromContent("commit"));
            assertThat(commit.Status(), @is(404));
        }
Example #24
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));
        }
Example #25
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));
        }
Example #26
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldSayMalformedHeaderIfMalformedAuthorization() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldSayMalformedHeaderIfMalformedAuthorization()
        {
            // Given
            StartServerWithConfiguredUser();

            // When
            HTTP.Response response = HTTP.withHeaders(HttpHeaders.AUTHORIZATION, "This makes no sense").GET(DataURL());

            // Then
            assertThat(response.Status(), equalTo(400));
            assertThat(response.Get("errors").get(0).get("code").asText(), equalTo("Neo.ClientError.Request.InvalidFormat"));
            assertThat(response.Get("errors").get(0).get("message").asText(), equalTo("Invalid authentication header."));
        }
Example #27
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldAddCorsHeaderWhenAuthEnabledAndPasswordChangeNotRequired() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldAddCorsHeaderWhenAuthEnabledAndPasswordChangeNotRequired()
        {
            StartServer(true);
            HTTP.Response passwordChangeResponse = ChangePassword("neo4j", "neo4j", "newPassword");
            assertEquals(OK.StatusCode, passwordChangeResponse.Status());
            AssertCorsHeaderPresent(passwordChangeResponse);

            HTTP.Response queryResponse = RunQuery("neo4j", "newPassword");

            assertEquals(OK.StatusCode, queryResponse.Status());
            AssertCorsHeaderPresent(queryResponse);
            assertThat(queryResponse.Content().ToString(), containsString("42"));
        }
Example #28
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private static void testPoint(String query, double[] expectedCoordinate, org.neo4j.values.storable.CoordinateReferenceSystem expectedCrs, String expectedType) throws Exception
        private static void TestPoint(string query, double[] expectedCoordinate, CoordinateReferenceSystem expectedCrs, string expectedType)
        {
            HTTP.Response response = RunQuery(query);

            assertEquals(200, response.Status());
            AssertNoErrors(response);

            JsonNode element = ExtractSingleElement(response);

            AssertGeometryTypeEqual(GeometryType.GEOMETRY_POINT, element);
            AssertCoordinatesEqual(expectedCoordinate, element);
            AssertCrsEqual(expectedCrs, element);

            AssertTypeEqual(expectedType, response);
        }
Example #29
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());
        }
Example #30
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));
        }