use of com.baidu.hugegraph.auth.HugeProject in project incubator-hugegraph by apache.
the class AuthTest method makeProjectAndAddGraph.
private static Id makeProjectAndAddGraph(HugeGraph graph, String projectName, String graphName) {
HugeProject project = makeProject(projectName, "");
AuthManager authManager = graph.authManager();
Id projectId = authManager.createProject(project);
projectId = authManager.projectAddGraphs(projectId, ImmutableSet.of(graphName));
Assert.assertNotNull(projectId);
return projectId;
}
use of com.baidu.hugegraph.auth.HugeProject in project incubator-hugegraph by apache.
the class AuthTest method clearAll.
@After
public void clearAll() {
HugeGraph graph = graph();
AuthManager authManager = graph.authManager();
for (HugeUser user : authManager.listAllUsers(-1)) {
authManager.deleteUser(user.id());
}
for (HugeGroup group : authManager.listAllGroups(-1)) {
authManager.deleteGroup(group.id());
}
for (HugeTarget target : authManager.listAllTargets(-1)) {
authManager.deleteTarget(target.id());
}
for (HugeProject project : authManager.listAllProject(-1)) {
if (!CollectionUtils.isEmpty(project.graphs())) {
authManager.projectRemoveGraphs(project.id(), project.graphs());
}
authManager.deleteProject(project.id());
}
Assert.assertEquals(0, authManager.listAllAccess(-1).size());
Assert.assertEquals(0, authManager.listAllBelong(-1).size());
}
use of com.baidu.hugegraph.auth.HugeProject in project incubator-hugegraph by apache.
the class AuthTest method testProjectRemoveGraph.
@Test
public void testProjectRemoveGraph() {
Id projectId = makeProjectAndAddGraph(graph(), "test_project", "graph_test");
AuthManager authManager = graph().authManager();
Assert.assertNotNull(projectId);
HugeProject project = authManager.getProject(projectId);
Assert.assertNotNull(project);
Assert.assertFalse(project.graphs().isEmpty());
projectId = authManager.projectRemoveGraphs(project.id(), ImmutableSet.of("graph_test"));
project = authManager.getProject(projectId);
Assert.assertNotNull(project);
Assert.assertTrue(project.graphs().isEmpty());
}
use of com.baidu.hugegraph.auth.HugeProject 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