Search in sources :

Example 11 with JsonPermission

use of io.lumeer.api.dto.JsonPermission in project engine by Lumeer.

the class ProjectServicePermissionsIT method testGetProjectPermissionsManageRole.

@Test
public void testGetProjectPermissionsManageRole() {
    String projectCode = "testGetProjectPermissionsManageRole_code1";
    String projectName = "testGetProjectPermissionsManageRole";
    createProject(projectCode, projectName);
    projectFacade.updateUserPermissions(projectCode, new JsonPermission(userEmail, Role.toStringRoles(new HashSet<>(Arrays.asList(Role.READ, Role.MANAGE)))));
    Response response = client.target(TARGET_URI).path(PATH_PREFIX + projectCode + "/permissions").request(MediaType.APPLICATION_JSON).buildGet().invoke();
    assertThat(response.getStatusInfo()).isEqualTo(Response.Status.OK);
}
Also used : Response(javax.ws.rs.core.Response) JsonPermission(io.lumeer.api.dto.JsonPermission) Test(org.junit.Test)

Example 12 with JsonPermission

use of io.lumeer.api.dto.JsonPermission in project engine by Lumeer.

the class ProjectServicePermissionsIT method testDeleteProjectInOrganizationManageRole.

@Test
public void testDeleteProjectInOrganizationManageRole() {
    String projectCode = "ProjectServiceTestProject_code1";
    String projectName = "ProjectServiceTestProject1";
    createProject(projectCode, projectName);
    projectFacade.updateUserPermissions(projectCode, new JsonPermission(userEmail, Role.toStringRoles(new HashSet<>(Arrays.asList(Role.READ, Role.MANAGE)))));
    Response response = client.target(TARGET_URI).path(PATH_PREFIX + projectCode).request(MediaType.APPLICATION_JSON).buildDelete().invoke();
    assertThat(response.getStatusInfo()).isEqualTo(Response.Status.OK);
}
Also used : Response(javax.ws.rs.core.Response) JsonPermission(io.lumeer.api.dto.JsonPermission) Test(org.junit.Test)

Example 13 with JsonPermission

use of io.lumeer.api.dto.JsonPermission in project engine by Lumeer.

the class CollectionServiceIT method testUpdateUserPermissions.

@Test
public void testUpdateUserPermissions() {
    String collectionId = createCollection(CODE).getId();
    SimplePermission userPermission = new SimplePermission(USER, new HashSet<>(Arrays.asList(Role.MANAGE, Role.READ)));
    Entity entity = Entity.json(userPermission);
    Response response = client.target(COLLECTIONS_URL).path(collectionId).path("permissions").path("users").request(MediaType.APPLICATION_JSON).buildPut(entity).invoke();
    assertThat(response).isNotNull();
    assertThat(response.getStatusInfo()).isEqualTo(Response.Status.OK);
    Set<JsonPermission> returnedPermissions = response.readEntity(new GenericType<Set<JsonPermission>>() {
    });
    assertThat(returnedPermissions).isNotNull().hasSize(1);
    assertPermissions(Collections.unmodifiableSet(returnedPermissions), userPermission);
    Permissions storedPermissions = collectionDao.getCollectionByCode(CODE).getPermissions();
    assertThat(storedPermissions).isNotNull();
    assertPermissions(storedPermissions.getUserPermissions(), userPermission);
    assertPermissions(storedPermissions.getGroupPermissions(), GROUP_PERMISSION);
}
Also used : Response(javax.ws.rs.core.Response) Entity(javax.ws.rs.client.Entity) HashSet(java.util.HashSet) Set(java.util.Set) LumeerAssertions.assertPermissions(io.lumeer.test.util.LumeerAssertions.assertPermissions) JsonPermissions(io.lumeer.api.dto.JsonPermissions) Permissions(io.lumeer.api.model.Permissions) JsonPermission(io.lumeer.api.dto.JsonPermission) SimplePermission(io.lumeer.core.model.SimplePermission) Test(org.junit.Test)

Example 14 with JsonPermission

use of io.lumeer.api.dto.JsonPermission in project engine by Lumeer.

the class CollectionServiceIT method testUpdateGroupPermissions.

@Test
public void testUpdateGroupPermissions() {
    String collectionId = createCollection(CODE).getId();
    SimplePermission groupPermission = new SimplePermission(GROUP, new HashSet<>(Arrays.asList(Role.SHARE, Role.READ)));
    Entity entity = Entity.json(groupPermission);
    Response response = client.target(COLLECTIONS_URL).path(collectionId).path("permissions").path("groups").request(MediaType.APPLICATION_JSON).buildPut(entity).invoke();
    assertThat(response).isNotNull();
    assertThat(response.getStatusInfo()).isEqualTo(Response.Status.OK);
    Set<JsonPermission> returnedPermissions = response.readEntity(new GenericType<Set<JsonPermission>>() {
    });
    assertThat(returnedPermissions).isNotNull().hasSize(1);
    assertPermissions(Collections.unmodifiableSet(returnedPermissions), groupPermission);
    Permissions storedPermissions = collectionDao.getCollectionByCode(CODE).getPermissions();
    assertThat(storedPermissions).isNotNull();
    assertPermissions(storedPermissions.getUserPermissions(), USER_PERMISSION);
    assertPermissions(storedPermissions.getGroupPermissions(), groupPermission);
}
Also used : Response(javax.ws.rs.core.Response) Entity(javax.ws.rs.client.Entity) HashSet(java.util.HashSet) Set(java.util.Set) LumeerAssertions.assertPermissions(io.lumeer.test.util.LumeerAssertions.assertPermissions) JsonPermissions(io.lumeer.api.dto.JsonPermissions) Permissions(io.lumeer.api.model.Permissions) JsonPermission(io.lumeer.api.dto.JsonPermission) SimplePermission(io.lumeer.core.model.SimplePermission) Test(org.junit.Test)

Example 15 with JsonPermission

use of io.lumeer.api.dto.JsonPermission in project engine by Lumeer.

the class GroupServiceIT method configure.

@Before
public void configure() {
    JsonOrganization organization1 = new JsonOrganization();
    organization1.setCode("LMR");
    organization1.setPermissions(new JsonPermissions());
    organization1.getPermissions().updateUserPermissions(new JsonPermission(USER, Role.toStringRoles(new HashSet<>(Arrays.asList(Role.WRITE, Role.READ, Role.MANAGE)))));
    organization = organizationDao.createOrganization(organization1);
    groupDao.createGroupsRepository(organization);
    groupDao.setOrganization(organization);
}
Also used : JsonPermissions(io.lumeer.api.dto.JsonPermissions) JsonOrganization(io.lumeer.api.dto.JsonOrganization) JsonPermission(io.lumeer.api.dto.JsonPermission) Before(org.junit.Before)

Aggregations

JsonPermission (io.lumeer.api.dto.JsonPermission)45 Response (javax.ws.rs.core.Response)29 Test (org.junit.Test)29 JsonOrganization (io.lumeer.api.dto.JsonOrganization)27 JsonPermissions (io.lumeer.api.dto.JsonPermissions)24 Organization (io.lumeer.api.model.Organization)22 Before (org.junit.Before)16 JsonProject (io.lumeer.api.dto.JsonProject)14 Project (io.lumeer.api.model.Project)13 User (io.lumeer.api.model.User)12 AuthenticatedUser (io.lumeer.core.AuthenticatedUser)12 SimplePermission (io.lumeer.core.model.SimplePermission)12 HashSet (java.util.HashSet)12 Permission (io.lumeer.api.model.Permission)9 JsonCollection (io.lumeer.api.dto.JsonCollection)8 Permissions (io.lumeer.api.model.Permissions)8 LumeerAssertions.assertPermissions (io.lumeer.test.util.LumeerAssertions.assertPermissions)8 Set (java.util.Set)8 Entity (javax.ws.rs.client.Entity)8 MorphiaPermission (io.lumeer.storage.mongodb.model.embedded.MorphiaPermission)4