Ejemplo n.º 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();
        }
Ejemplo n.º 2
0
 public NamedFunctionAnonymousInnerClass(ThreadedTransaction <S> outerInstance, S subject, KernelTransaction.Type txType, bool startEarly, string[] queries) : base("threaded-transaction-" + Arrays.GetHashCode(queries))
 {
     this.outerInstance = outerInstance;
     this._subject      = subject;
     this._txType       = txType;
     this._startEarly   = startEarly;
     this._queries      = queries;
 }
Ejemplo n.º 3
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");
        }
Ejemplo n.º 4
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);
        }