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);
}
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);
}
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);
}
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);
}
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);
}
Aggregations