Search in sources :

Example 6 with TestAccessMode

use of org.neo4j.internal.kernel.api.security.TestAccessMode in project neo4j by neo4j.

the class NodeTransactionStateTestBase method shouldNotCountRemovedNodesFromTxStateRestrictedUser.

@Test
void shouldNotCountRemovedNodesFromTxStateRestrictedUser() throws Exception {
    // Given
    Node node1 = createNode("label");
    Node node2 = createNode("label");
    SecurityContext loginContext = new SecurityContext(AuthSubject.AUTH_DISABLED, new TestAccessMode(true, false, true, false), EMBEDDED_CONNECTION, null);
    try (KernelTransaction tx = beginTransaction(loginContext)) {
        // when
        tx.dataWrite().nodeDelete(node2.node);
        long countTxState = tx.dataRead().countsForNode(node1.labels[0]);
        long countNoTxState = tx.dataRead().countsForNodeWithoutTxState(node1.labels[0]);
        // then
        assertEquals(1, countTxState);
        assertEquals(2, countNoTxState);
    }
}
Also used : KernelTransaction(org.neo4j.kernel.api.KernelTransaction) SecurityContext(org.neo4j.internal.kernel.api.security.SecurityContext) TestAccessMode(org.neo4j.internal.kernel.api.security.TestAccessMode) Test(org.junit.jupiter.api.Test)

Example 7 with TestAccessMode

use of org.neo4j.internal.kernel.api.security.TestAccessMode in project neo4j by neo4j.

the class NodeTransactionStateTestBase method shouldNotCountRemovedLabelsFromTxStateRestrictedUser.

@Test
void shouldNotCountRemovedLabelsFromTxStateRestrictedUser() throws Exception {
    // Given
    Node node1 = createNode("label");
    Node node2 = createNode("label");
    SecurityContext loginContext = new SecurityContext(AuthSubject.AUTH_DISABLED, new TestAccessMode(true, false, true, false), EMBEDDED_CONNECTION, null);
    try (KernelTransaction tx = beginTransaction(loginContext)) {
        // when
        tx.dataWrite().nodeRemoveLabel(node2.node, node2.labels[0]);
        long countTxState = tx.dataRead().countsForNode(node1.labels[0]);
        long countNoTxState = tx.dataRead().countsForNodeWithoutTxState(node1.labels[0]);
        // then
        assertEquals(1, countTxState);
        assertEquals(2, countNoTxState);
    }
}
Also used : KernelTransaction(org.neo4j.kernel.api.KernelTransaction) SecurityContext(org.neo4j.internal.kernel.api.security.SecurityContext) TestAccessMode(org.neo4j.internal.kernel.api.security.TestAccessMode) Test(org.junit.jupiter.api.Test)

Aggregations

Test (org.junit.jupiter.api.Test)7 SecurityContext (org.neo4j.internal.kernel.api.security.SecurityContext)7 TestAccessMode (org.neo4j.internal.kernel.api.security.TestAccessMode)7 KernelTransaction (org.neo4j.kernel.api.KernelTransaction)7 Write (org.neo4j.internal.kernel.api.Write)3 NodeCursor (org.neo4j.internal.kernel.api.NodeCursor)1 Read (org.neo4j.internal.kernel.api.Read)1 RelationshipTraversalCursor (org.neo4j.internal.kernel.api.RelationshipTraversalCursor)1