Exemple #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldHavePredefinedRoles() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldHavePredefinedRoles()
        {
            // Given
            StartServerWithConfiguredUser();

            // When
            string method = "POST";
            string path   = "db/data/transaction/commit";

            HTTP.RawPayload payload  = HTTP.RawPayload.quotedJson("{'statements':[{'statement':'CALL dbms.security.listRoles()'}]}");
            HTTP.Response   response = HTTP.withBasicAuth("neo4j", "secret").request(method, Server.baseUri().resolve(path).ToString(), payload);

            // Then
            assertThat(response.Status(), equalTo(200));
            ArrayNode errors = ( ArrayNode )response.Get("errors");

            assertThat("Should have no errors", errors.size(), equalTo(0));
            ArrayNode results = ( ArrayNode )response.Get("results");
            ArrayNode data    = ( ArrayNode )results.get(0).get("data");

            assertThat("Should have 5 predefined roles", data.size(), equalTo(5));
            Stream <string> values = data.findValues("row").Select(row => row.get(0).asText());

            assertThat("Expected specific roles", values.collect(Collectors.toList()), hasItems("admin", "architect", "publisher", "editor", "reader"));
        }
Exemple #2
0
        private object GetValue(JsonNode valueNode)
        {
            object value;

            if (valueNode is TextNode)
            {
                value = valueNode.asText();
            }
            else if (valueNode is ObjectNode)
            {
                value = MapValue(valueNode.FieldNames, valueNode);
            }
            else if (valueNode is ArrayNode)
            {
                ArrayNode     aNode     = ( ArrayNode )valueNode;
                List <string> listValue = new List <string>(aNode.size());
                for (int j = 0; j < aNode.size(); j++)
                {
                    listValue.Add(aNode.get(j).asText());
                }
                value = listValue;
            }
            else if (valueNode is IntNode)
            {
                value = valueNode.IntValue;
            }
            else if (valueNode is LongNode)
            {
                value = valueNode.LongValue;
            }
            else if (valueNode.Null)
            {
                return(null);
            }
            else
            {
                throw new Exception(string.Format("Unhandled REST value type '{0}'. Need String (TextNode), List (ArrayNode), Object (ObjectNode), " + "long (LongNode), or int (IntNode).", valueNode.GetType()));
            }
            return(value);
        }
Exemple #3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldAllowExecutingEnterpriseBuiltInProceduresWithAuthDisabled() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldAllowExecutingEnterpriseBuiltInProceduresWithAuthDisabled()
        {
            // Given
            StartServerWithAuthDisabled();

            // When
            string method = "POST";
            string path   = "db/data/transaction/commit";

            HTTP.RawPayload payload  = HTTP.RawPayload.quotedJson("{'statements':[{'statement':'CALL dbms.listQueries()'}]}");
            HTTP.Response   response = HTTP.request(method, Server.baseUri().resolve(path).ToString(), payload);

            // Then
            assertThat(response.Status(), equalTo(200));
            ArrayNode errors = ( ArrayNode )response.Get("errors");

            assertThat("Should have no errors", errors.size(), equalTo(0));
            ArrayNode results = ( ArrayNode )response.Get("results");
            ArrayNode data    = ( ArrayNode )results.get(0).get("data");

            assertThat("Should see our own query", data.size(), equalTo(1));
        }