Ejemplo n.º 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));
        }
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 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."));
        }
Ejemplo n.º 3
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());
        }
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 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.º 5
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);
        }
Ejemplo n.º 6
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private static org.codehaus.jackson.JsonNode getSingleData(org.neo4j.test.server.HTTP.Response response) throws org.neo4j.server.rest.domain.JsonParseException
        private static JsonNode GetSingleData(HTTP.Response response)
        {
            JsonNode data = response.Get("results").get(0).get("data");

            assertEquals(1, data.size());
            return(data.get(0));
        }
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 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();
            }
        }
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 shouldRedirectRootToBrowser()
        public virtual void ShouldRedirectRootToBrowser()
        {
            assertFalse(Server().baseUri().ToString().Contains("browser"));

            HTTP.Response res = HTTP.withHeaders(HttpHeaders.ACCEPT, MediaType.TEXT_HTML).GET(Server().baseUri().ToString());
            assertThat(res.Header("Location"), containsString("browser"));
        }
Ejemplo n.º 9
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private static void assertTypeEqual(String expectedType, org.neo4j.test.server.HTTP.Response response) throws org.neo4j.server.rest.domain.JsonParseException
        private static void AssertTypeEqual(string expectedType, HTTP.Response response)
        {
            JsonNode data = response.Get("results").get(0).get("data");
            JsonNode meta = data.get(0).get("meta");

            assertEquals(1, meta.size());
            assertEquals(expectedType, meta.get(0).get("type").asText());
        }
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 periodicCommitTest() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void PeriodicCommitTest()
        {
            ServerTestUtils.withCSVFile(2, url =>
            {
                // begin
                HTTP.Response begin = _http.POST("db/data/cypher", quotedJson("{ 'query': 'USING PERIODIC COMMIT 100 LOAD CSV FROM \\\"" + url + "\\\" AS line CREATE ();' }"));
                assertThat(begin.status(), equalTo(200));
            });
        }
Ejemplo n.º 11
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)));
        }
Ejemplo n.º 12
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");
        }
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 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");
        }
Ejemplo n.º 14
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"));
        }
Ejemplo n.º 15
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");
        }
Ejemplo n.º 16
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");
        }
Ejemplo n.º 17
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"));
        }
Ejemplo n.º 18
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");
        }
Ejemplo n.º 19
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"));
        }
Ejemplo n.º 20
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private static org.codehaus.jackson.JsonNode extractSingleElement(org.neo4j.test.server.HTTP.Response response) throws org.neo4j.server.rest.domain.JsonParseException
        private static JsonNode ExtractSingleElement(HTTP.Response response)
        {
            JsonNode data = response.Get("results").get(0).get("data");

            assertEquals(1, data.size());
            JsonNode row = data.get(0).get("row");

            assertEquals(1, row.size());
            return(row.get(0));
        }
Ejemplo n.º 21
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");
        }
Ejemplo n.º 22
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));
        }
Ejemplo n.º 23
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.º 24
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.º 25
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void txEndpointShouldReplyWithHttpsWhenItReturnsURLs() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void TxEndpointShouldReplyWithHttpsWhenItReturnsURLs()
        {
            StartServer();

            string baseUri = _server.baseUri().ToString();

            HTTP.Response response = POST(baseUri + "db/data/transaction", quotedJson("{'statements':[]}"));

            assertThat(response.Location(), startsWith(baseUri));
            assertThat(response.Get("commit").asText(), startsWith(baseUri));
        }
Ejemplo n.º 26
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.º 27
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));
        }
Ejemplo n.º 28
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());
        }
Ejemplo n.º 29
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.º 30
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));
        }