clearResourceAccess();
try {
List<TestUser> users = createTestNodes(TestUser.class, 2);
TestUser user1 = (TestUser) users.get(0);
TestUser user2 = (TestUser) users.get(1);
Result result = null;
// Let user 1 create a node
Class type = TestOne.class;
final TestOne t1 = createTestNode(TestOne.class, user1);
try (final Tx tx = app.tx()) {
// Grant read permission to user 2
user2.grant(Permission.read, t1);
tx.success();
}
// Let user 2 search
SecurityContext user2Context = SecurityContext.getInstance(user2, AccessMode.Backend);
try (final Tx tx = app.tx()) {
result = StructrApp.getInstance(user2Context).nodeQuery(type).getResult();
assertEquals(1, result.size());
assertEquals(t1.getUuid(), result.get(0).getUuid());
}
try (final Tx tx = app.tx()) {
// Revoke permission again
user2.revoke(Permission.read, t1);
tx.success();
}
try (final Tx tx = app.tx()) {