Пример #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldNotKillQueryIfNotAuthenticated() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldNotKillQueryIfNotAuthenticated()
        {
            EnterpriseLoginContext unAuthSubject = CreateFakeAnonymousEnterpriseLoginContext();

            GraphDatabaseFacade graph = Neo.LocalGraph;
            DoubleLatch         latch = new DoubleLatch(2);
            ThreadedTransaction <EnterpriseLoginContext> read = new ThreadedTransaction <EnterpriseLoginContext>(Neo, latch);
            string query = read.Execute(ThreadingConflict, ReadSubject, "UNWIND [1,2,3] AS x RETURN x");

            latch.StartAndWaitForAllToStart();

            string id = ExtractQueryId(query);

            try
            {
                using (InternalTransaction tx = graph.BeginTransaction(KernelTransaction.Type.@explicit, unAuthSubject))
                {
                    graph.execute(tx, "CALL dbms.killQuery('" + id + "')", EMPTY_MAP);
                    throw new AssertionError("Expected exception to be thrown");
                }
            }
            catch (QueryExecutionException e)
            {
                assertThat(e.Message, containsString(PERMISSION_DENIED));
            }

            latch.FinishAndWaitForAllToFinish();
            read.CloseAndAssertSuccess();
        }
Пример #2
0
        /*
         * Admin creates user Henrik with password bar
         * Admin adds user Henrik to role Publisher
         * Henrik logs in with correct password
         * Henrik starts transaction with long running writing query Q
         * Admin removes user Henrik from role Publisher (while Q still running)
         * Q finishes and transaction is committed → ok
         * Henrik starts new transaction with write query → permission denied
         */
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void roleManagement5() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void RoleManagement5()
        {
            AssertEmpty(AdminSubject, "CALL dbms.security.createUser('Henrik', 'bar', false)");
            AssertEmpty(AdminSubject, "CALL dbms.security.addRoleToUser('" + PUBLISHER + "', 'Henrik')");
            S henrik = Neo.login("Henrik", "bar");

            Neo.assertAuthenticated(henrik);

            DoubleLatch             latch = new DoubleLatch(2);
            ThreadedTransaction <S> write = new ThreadedTransaction <S>(Neo, latch);

            write.ExecuteCreateNode(ThreadingConflict, henrik);
            latch.StartAndWaitForAllToStart();

            AssertEmpty(AdminSubject, "CALL dbms.security.removeRoleFromUser('" + PUBLISHER + "', 'Henrik')");

            latch.FinishAndWaitForAllToFinish();

            write.CloseAndAssertSuccess();
            TestFailWrite(henrik);
        }