use of com.baidu.hugegraph.auth.HugeAccess in project incubator-hugegraph by apache.
the class AuthTest method testGetAccess.
@Test
public void testGetAccess() {
HugeGraph graph = graph();
AuthManager authManager = graph.authManager();
Id group = authManager.createGroup(makeGroup("group1"));
Id target1 = authManager.createTarget(makeTarget("graph1", "url1"));
Id target2 = authManager.createTarget(makeTarget("graph2", "url2"));
Id id1 = authManager.createAccess(makeAccess(group, target1, HugePermission.READ));
Id id2 = authManager.createAccess(makeAccess(group, target2, HugePermission.READ));
HugeAccess access1 = authManager.getAccess(id1);
Assert.assertEquals(target1, access1.target());
HugeAccess access2 = authManager.getAccess(id2);
Assert.assertEquals(target2, access2.target());
Assert.assertThrows(NotFoundException.class, () -> {
authManager.getAccess(IdGenerator.of("fake"));
});
Assert.assertThrows(NotFoundException.class, () -> {
authManager.getAccess(null);
});
Assert.assertThrows(IllegalArgumentException.class, () -> {
Id user = authManager.createUser(makeUser("tom", "pass1"));
Id belong = authManager.createBelong(makeBelong(user, group));
authManager.getAccess(belong);
});
}
Aggregations