use of io.lumeer.api.dto.JsonPermission in project engine by Lumeer.
the class OrganizationServicePermissionsIT method testGetOrganizationReadRole.
@Test
public void testGetOrganizationReadRole() {
String name = "TestGetOrganizationReadRole";
String code = "TestGetOrganizationReadRole_id";
Organization organization = new JsonOrganization(code, name, "a", "b", null, null);
organizationFacade.createOrganization(organization);
Permission newPermission = new JsonPermission(userEmail, Role.toStringRoles(Collections.singleton(Role.READ)));
organizationFacade.updateUserPermissions(code, newPermission);
Set<Permission> perm = organizationDao.getOrganizationByCode(code).getPermissions().getUserPermissions();
LumeerAssertions.assertPermissions(perm, newPermission);
Response response = client.target(TARGET_URI).path(PATH_PREFIX + code).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 OrganizationServicePermissionsIT method testRemoveUserPermissionManageRole.
@Test
public void testRemoveUserPermissionManageRole() {
String name = "testRemoveUserPermissionNoRole";
String code = "testRemoveUserPermissionNoRole_code";
Organization organization = new JsonOrganization(code, name, "a", "b", null, null);
organizationFacade.createOrganization(organization);
organizationFacade.updateUserPermissions(code, new JsonPermission(userEmail, Role.toStringRoles(new HashSet<Role>(Arrays.asList(Role.READ, Role.MANAGE)))));
Response response = client.target(TARGET_URI).path(PATH_PREFIX + code + "/permissions/users/" + userEmail).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 OrganizationServicePermissionsIT method testUpdateOrganizationManageRole.
@Test
public void testUpdateOrganizationManageRole() {
String name = "TestUpdateOrganizationManageRole";
String code = "TestUpdateOrganizationManageRole_code";
String newName = "NewTestUpdateOrganizationManageRole";
Organization organization = new JsonOrganization(code, name, "a", "b", null, null);
organizationFacade.createOrganization(organization);
organizationFacade.updateUserPermissions(code, new JsonPermission(userEmail, Role.toStringRoles(new HashSet<Role>(Arrays.asList(Role.READ, Role.MANAGE)))));
Response response = client.target(TARGET_URI).path(PATH_PREFIX + code).request(MediaType.APPLICATION_JSON).buildPut(Entity.json(new JsonOrganization(code, newName, "c", "d", null, null))).invoke();
assertThat(response.getStatusInfo()).isEqualTo(Response.Status.OK);
Organization org = response.readEntity(JsonOrganization.class);
assertThat(org.getName()).isEqualTo(newName);
assertThat(org.getCode()).isEqualTo(code);
}
use of io.lumeer.api.dto.JsonPermission in project engine by Lumeer.
the class OrganizationServicePermissionsIT method testUpdateGroupPermissionNoRole.
@Test
public void testUpdateGroupPermissionNoRole() {
String name = "testUpdateGroupPermissionNoRole";
String code = "testUpdateGroupPermissionNoRole_code";
Organization organization = new JsonOrganization(code, name, "a", "b", null, null);
organizationFacade.createOrganization(organization);
organizationFacade.removeUserPermission(code, userEmail);
String group = "testGroup1";
Permission newPermission = new JsonPermission(group, Role.toStringRoles(new HashSet<>(Collections.singletonList(Role.WRITE))));
Response response = client.target(TARGET_URI).path(PATH_PREFIX + code + "/permissions/groups").request(MediaType.APPLICATION_JSON).buildPut(Entity.json(newPermission)).invoke();
assertThat(response.getStatusInfo()).isEqualTo(Response.Status.UNAUTHORIZED);
}
use of io.lumeer.api.dto.JsonPermission in project engine by Lumeer.
the class ProjectServicePermissionsIT method tesRemoveUserPermissionsManageRole.
@Test
public void tesRemoveUserPermissionsManageRole() {
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)))));
Response response = client.target(TARGET_URI).path(PATH_PREFIX + projectCode + "/permissions/users/" + userEmail).request(MediaType.APPLICATION_JSON).buildDelete().invoke();
assertThat(response.getStatusInfo()).isEqualTo(Response.Status.OK);
}
Aggregations