Search in sources :

Example 6 with HugeProject

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

the class AuthTest method testUpdateProject.

@Test
public void testUpdateProject() {
    HugeProject project = makeProject("test_project", "this is a desc");
    AuthManager authManager = graph().authManager();
    Id projectId = authManager.createProject(project);
    project = authManager.getProject(projectId);
    project.description("this is a desc another");
    projectId = authManager.updateProject(project);
    HugeProject newProject = authManager.getProject(projectId);
    Assert.assertEquals("this is a desc another", newProject.description());
}
Also used : HugeProject(com.baidu.hugegraph.auth.HugeProject) AuthManager(com.baidu.hugegraph.auth.AuthManager) Id(com.baidu.hugegraph.backend.id.Id) Test(org.junit.Test)

Example 7 with HugeProject

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

the class AuthTest method testDelProject.

@Test
public void testDelProject() {
    HugeProject project = makeProject("test_project", null);
    AuthManager authManager = graph().authManager();
    Id projectId = authManager.createProject(project);
    Assert.assertNotNull(projectId);
    HugeProject deletedProject = authManager.deleteProject(projectId);
    Assert.assertThrows(NotFoundException.class, () -> {
        authManager.getProject(projectId);
    });
    Assert.assertThrows(NotFoundException.class, () -> {
        authManager.getGroup(IdGenerator.of(deletedProject.adminGroupId()));
    });
    Assert.assertThrows(NotFoundException.class, () -> {
        authManager.getGroup(IdGenerator.of(deletedProject.opGroupId()));
    });
    Assert.assertThrows(NotFoundException.class, () -> {
        authManager.getTarget(IdGenerator.of(deletedProject.targetId()));
    });
}
Also used : HugeProject(com.baidu.hugegraph.auth.HugeProject) AuthManager(com.baidu.hugegraph.auth.AuthManager) Id(com.baidu.hugegraph.backend.id.Id) Test(org.junit.Test)

Example 8 with HugeProject

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

the class AuthTest method testProjectAddGraph.

@Test
public void testProjectAddGraph() {
    HugeProject project = makeProject("test_project", "");
    AuthManager authManager = graph().authManager();
    Id projectId = authManager.createProject(project);
    projectId = authManager.projectAddGraphs(projectId, ImmutableSet.of("graph_test"));
    Assert.assertNotNull(projectId);
    project = authManager.getProject(projectId);
    Assert.assertFalse(project.graphs().isEmpty());
}
Also used : HugeProject(com.baidu.hugegraph.auth.HugeProject) AuthManager(com.baidu.hugegraph.auth.AuthManager) Id(com.baidu.hugegraph.backend.id.Id) Test(org.junit.Test)

Example 9 with HugeProject

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

the class AuthTest method makeProject.

private static HugeProject makeProject(String name, String desc) {
    HugeProject project = new HugeProject(name, desc);
    project.creator("admin");
    return project;
}
Also used : HugeProject(com.baidu.hugegraph.auth.HugeProject)

Example 10 with HugeProject

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

the class AuthTest method testCreateProject.

@Test
public void testCreateProject() {
    HugeGraph graph = graph();
    HugeProject project = makeProject("test_project", "this is a test project");
    Id id = graph.authManager().createProject(project);
    Assert.assertNotNull(id);
    project = graph.authManager().getProject(id);
    Assert.assertNotNull(project);
    Assert.assertEquals("this is a test project", project.description());
    Assert.assertEquals("test_project", project.name());
    Assert.assertNotNull(project.adminGroupId());
    Assert.assertNotNull(project.opGroupId());
    Assert.assertNotNull(project.targetId());
    // Check name is unique index
    HugeProject sameNameProject = makeProject("test_project", "this is a test " + "project another");
    Assert.assertThrows(HugeException.class, () -> {
        graph.authManager().createProject(sameNameProject);
    });
}
Also used : HugeGraph(com.baidu.hugegraph.HugeGraph) HugeProject(com.baidu.hugegraph.auth.HugeProject) Id(com.baidu.hugegraph.backend.id.Id) Test(org.junit.Test)

Aggregations

HugeProject (com.baidu.hugegraph.auth.HugeProject)14 AuthManager (com.baidu.hugegraph.auth.AuthManager)8 Id (com.baidu.hugegraph.backend.id.Id)8 Test (org.junit.Test)7 HugeGraph (com.baidu.hugegraph.HugeGraph)6 Timed (com.codahale.metrics.annotation.Timed)4 Produces (jakarta.ws.rs.Produces)4 NotFoundException (com.baidu.hugegraph.exception.NotFoundException)2 Consumes (jakarta.ws.rs.Consumes)2 GET (jakarta.ws.rs.GET)2 Path (jakarta.ws.rs.Path)2 HugeGroup (com.baidu.hugegraph.auth.HugeGroup)1 HugeResource (com.baidu.hugegraph.auth.HugeResource)1 HugeTarget (com.baidu.hugegraph.auth.HugeTarget)1 HugeUser (com.baidu.hugegraph.auth.HugeUser)1 POST (jakarta.ws.rs.POST)1 PUT (jakarta.ws.rs.PUT)1 After (org.junit.After)1