use of io.lumeer.api.model.Permission in project engine by Lumeer.
the class ProjectServicePermissionsIT method testUpdateUserPermissionsManageRole.
@Test
public void testUpdateUserPermissionsManageRole() {
String projectCode = "testGetProjectPermissionsNoRole_code1";
String projectName = "testGetProjectPermissionsNoRole";
createProject(projectCode, projectName);
projectFacade.updateUserPermissions(projectCode, new JsonPermission(userEmail, Role.toStringRoles(new HashSet<>(Arrays.asList(Role.READ, Role.MANAGE)))));
Permission newPermission = new JsonPermission(userEmail, Role.toStringRoles(new HashSet<>(Arrays.asList(Role.WRITE))));
Response response = client.target(TARGET_URI).path(PATH_PREFIX + projectCode + "/permissions/users").request(MediaType.APPLICATION_JSON).buildPut(Entity.json(newPermission)).invoke();
assertThat(response.getStatusInfo()).isEqualTo(Response.Status.OK);
}
use of io.lumeer.api.model.Permission in project engine by Lumeer.
the class ProjectServicePermissionsIT method testUpdateGroupPermissionsManageRole.
@Test
public void testUpdateGroupPermissionsManageRole() {
String projectCode = "testGetProjectPermissionsNoRole_code1";
String projectName = "testGetProjectPermissionsNoRole";
createProject(projectCode, projectName);
projectFacade.updateUserPermissions(projectCode, new JsonPermission(userEmail, Role.toStringRoles(new HashSet<>(Arrays.asList(Role.READ, Role.MANAGE)))));
String group = "testGroup5";
Permission newPermission = new JsonPermission(group, Role.toStringRoles(new HashSet<>(Arrays.asList(Role.WRITE))));
Response response = client.target(TARGET_URI).path(PATH_PREFIX + projectCode + "/permissions/groups").request(MediaType.APPLICATION_JSON).buildPut(Entity.json(newPermission)).invoke();
assertThat(response.getStatusInfo()).isEqualTo(Response.Status.OK);
}
use of io.lumeer.api.model.Permission in project engine by Lumeer.
the class PermissionsCodec method convertFromDocument.
public static JsonPermissions convertFromDocument(final Document document) {
if (document == null) {
return new JsonPermissions();
}
Permission[] userPermissions = new ArrayList<Document>(document.get(USER_ROLES, List.class)).stream().map(PermissionCodec::convertFromDocument).toArray(Permission[]::new);
Permission[] groupPermissions = new ArrayList<Document>(document.get(GROUP_ROLES, List.class)).stream().map(PermissionCodec::convertFromDocument).toArray(Permission[]::new);
JsonPermissions permissions = new JsonPermissions();
permissions.updateUserPermissions(userPermissions);
permissions.updateGroupPermissions(groupPermissions);
return permissions;
}
Aggregations