use of com.baidu.hugegraph.auth.HugeResource in project incubator-hugegraph by apache.
the class RolePermissionTest method testHugeResourceFilterUser.
@Test
public void testHugeResourceFilterUser() {
HugeResource all = HugeResource.ALL;
// user
ResourceObject<?> r3 = ResourceObject.of("g1", ResourceType.USER_GROUP, NameObject.ANY);
Assert.assertFalse(all.filter(r3));
HugeResource user = new HugeResource(ResourceType.USER_GROUP, HugeResource.ANY, null);
Assert.assertTrue(user.filter(r3));
ResourceObject<?> r4 = ResourceObject.of("g1", new HugeUser("fake"));
Assert.assertTrue(user.filter(r4));
HugeResource user2 = new HugeResource(ResourceType.USER_GROUP, "bj-.*", null);
Assert.assertTrue(user2.filter(r3));
Assert.assertFalse(user2.filter(r4));
HugeResource user3 = new HugeResource(ResourceType.USER_GROUP, "fa.*", null);
Assert.assertTrue(user3.filter(r3));
Assert.assertTrue(user3.filter(r4));
ResourceObject<?> r5 = ResourceObject.of("g1", new HugeTarget("g", ""));
Assert.assertFalse(user.filter(r5));
HugeResource root = new HugeResource(ResourceType.ROOT, HugeResource.ANY, null);
Assert.assertTrue(root.filter(r3));
Assert.assertTrue(root.filter(r4));
Assert.assertTrue(root.filter(r5));
}
use of com.baidu.hugegraph.auth.HugeResource in project incubator-hugegraph by apache.
the class RolePermissionTest method testHugeResourceFilterProject.
@Test
public void testHugeResourceFilterProject() {
HugeResource all = HugeResource.ALL;
ResourceObject<?> r1 = ResourceObject.of("hugegraph", new HugeProject("project1"));
Assert.assertFalse(all.filter(r1));
HugeResource project = new HugeResource(ResourceType.PROJECT, "project1", null);
Assert.assertTrue(project.filter(r1));
HugeResource root = new HugeResource(ResourceType.ROOT, HugeResource.ANY, null);
Assert.assertTrue(root.filter(r1));
ResourceObject<?> r2 = ResourceObject.of("hugegraph", new HugeProject("project2"));
Assert.assertFalse(project.filter(r2));
}
Aggregations