Search in sources :

Example 11 with HugeGroup

use of com.baidu.hugegraph.auth.HugeGroup 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());
}
Also used : HugeGraph(com.baidu.hugegraph.HugeGraph) AuthManager(com.baidu.hugegraph.auth.AuthManager) HugeProject(com.baidu.hugegraph.auth.HugeProject) HugeGroup(com.baidu.hugegraph.auth.HugeGroup) HugeTarget(com.baidu.hugegraph.auth.HugeTarget) HugeUser(com.baidu.hugegraph.auth.HugeUser) After(org.junit.After)

Example 12 with HugeGroup

use of com.baidu.hugegraph.auth.HugeGroup in project incubator-hugegraph by apache.

the class AuthTest method testUpdateGroup.

@Test
public void testUpdateGroup() throws InterruptedException {
    HugeGraph graph = graph();
    AuthManager authManager = graph.authManager();
    HugeGroup group = makeGroup("group1");
    group.description("description1");
    Id id = authManager.createGroup(group);
    group = authManager.getGroup(id);
    Assert.assertEquals("group1", group.name());
    Assert.assertEquals("description1", group.description());
    Assert.assertEquals(group.create(), group.update());
    Date oldUpdateTime = group.update();
    Thread.sleep(1L);
    group.description("description2");
    authManager.updateGroup(group);
    HugeGroup group2 = authManager.getGroup(id);
    Assert.assertEquals("group1", group2.name());
    Assert.assertEquals("description2", group2.description());
    Assert.assertEquals(oldUpdateTime, group2.create());
    Assert.assertNotEquals(oldUpdateTime, group2.update());
}
Also used : HugeGraph(com.baidu.hugegraph.HugeGraph) AuthManager(com.baidu.hugegraph.auth.AuthManager) HugeGroup(com.baidu.hugegraph.auth.HugeGroup) Id(com.baidu.hugegraph.backend.id.Id) Date(java.util.Date) Test(org.junit.Test)

Aggregations

HugeGroup (com.baidu.hugegraph.auth.HugeGroup)12 HugeGraph (com.baidu.hugegraph.HugeGraph)11 AuthManager (com.baidu.hugegraph.auth.AuthManager)7 Test (org.junit.Test)6 Id (com.baidu.hugegraph.backend.id.Id)5 Timed (com.codahale.metrics.annotation.Timed)4 Produces (jakarta.ws.rs.Produces)4 Consumes (jakarta.ws.rs.Consumes)2 GET (jakarta.ws.rs.GET)2 Path (jakarta.ws.rs.Path)2 Status (com.baidu.hugegraph.api.filter.StatusFilter.Status)1 HugeProject (com.baidu.hugegraph.auth.HugeProject)1 HugeTarget (com.baidu.hugegraph.auth.HugeTarget)1 HugeUser (com.baidu.hugegraph.auth.HugeUser)1 NotFoundException (com.baidu.hugegraph.exception.NotFoundException)1 POST (jakarta.ws.rs.POST)1 PUT (jakarta.ws.rs.PUT)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 After (org.junit.After)1