Exemplo n.º 1
0
        // --------------------- helpers -----------------------
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: void shouldTerminateTransactionsForUser(S subject, String procedure) throws Throwable
        internal virtual void ShouldTerminateTransactionsForUser(S subject, string procedure)
        {
            DoubleLatch             latch      = new DoubleLatch(2);
            ThreadedTransaction <S> userThread = new ThreadedTransaction <S>(Neo, latch);

            userThread.ExecuteCreateNode(Threading(), subject);
            latch.StartAndWaitForAllToStart();

            AssertEmpty(AdminSubject, "CALL " + format(procedure, Neo.nameOf(subject)));

            IDictionary <string, long> transactionsByUser = CountTransactionsByUsername();

            assertThat(transactionsByUser[Neo.nameOf(subject)], equalTo(null));

            latch.FinishAndWaitForAllToFinish();

            userThread.CloseAndAssertExplicitTermination();

            AssertEmpty(AdminSubject, "MATCH (n:Test) RETURN n.name AS name");
        }
Exemplo n.º 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);
        }