use of io.lumeer.api.dto.JsonPermission in project engine by Lumeer.
the class ProjectServicePermissionsIT method testGetProjectReadRole.
@Test
public void testGetProjectReadRole() {
String projectCode = "testGetProjectReadRole_code";
String projectName = "testGetProjectReadRole";
createProject(projectCode, projectName);
projectFacade.updateUserPermissions(projectCode, new JsonPermission(userEmail, Role.toStringRoles(new HashSet<>(Arrays.asList(Role.READ)))));
Response response = client.target(TARGET_URI).path(PATH_PREFIX + projectCode).request(MediaType.APPLICATION_JSON).buildGet().invoke();
assertThat(response.getStatusInfo()).isEqualTo(Response.Status.OK);
JsonOrganization fetchedProject = response.readEntity(JsonOrganization.class);
assertThat(fetchedProject.getCode()).isEqualTo(projectCode);
assertThat(fetchedProject.getName()).isEqualTo(projectName);
}
use of io.lumeer.api.dto.JsonPermission in project engine by Lumeer.
the class ProjectServicePermissionsIT method testGetProjectsSomeReadRoles.
@Test
public void testGetProjectsSomeReadRoles() {
String projectCode1 = "ProjectServiceTestProject_code1";
String projectName1 = "ProjectServiceTestProject1";
String projectCode2 = "ProjectServiceTestProject_code2";
String projectName2 = "ProjectServiceTestProject2";
String projectCode3 = "ProjectServiceTestProject_code3";
String projectName3 = "ProjectServiceTestProject3";
String projectCode4 = "ProjectServiceTestProject_code4";
String projectName4 = "ProjectServiceTestProject4";
List<String> projectCodes = Arrays.asList(projectCode1, projectCode2, projectCode3, projectCode4);
List<String> projectNames = Arrays.asList(projectName1, projectName2, projectName3, projectName4);
for (int i = 0; i < projectCodes.size(); i++) {
createProject(projectCodes.get(i), projectNames.get(i));
if (i % 2 == 0) {
projectFacade.removeUserPermission(projectCodes.get(i), userEmail);
} else {
projectFacade.updateUserPermissions(projectCodes.get(i), new JsonPermission(userEmail, Role.toStringRoles(new HashSet<>(Arrays.asList(Role.READ)))));
}
}
Response response = client.target(TARGET_URI).path(PATH_PREFIX).request(MediaType.APPLICATION_JSON).buildGet().invoke();
assertThat(response.getStatusInfo()).isEqualTo(Response.Status.OK);
List<Project> projects = response.readEntity(new GenericType<List<Project>>(List.class) {
});
assertThat(projects).extracting("code").containsOnly(projectCode2, projectCode4);
assertThat(projects).extracting("name").containsOnly(projectName2, projectName4);
}
use of io.lumeer.api.dto.JsonPermission 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.dto.JsonPermission 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.dto.JsonPermission in project engine by Lumeer.
the class ProjectServicePermissionsIT method testRemoveGroupPermissionsManageRole.
@Test
public void testRemoveGroupPermissionsManageRole() {
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 = "testGroup7";
Response response = client.target(TARGET_URI).path(PATH_PREFIX + projectCode + "/permissions/groups/" + group).request(MediaType.APPLICATION_JSON).buildDelete().invoke();
assertThat(response.getStatusInfo()).isEqualTo(Response.Status.OK);
}
Aggregations