Search in sources :

Example 6 with JsonPermission

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

the class OrganizationServicePermissionsIT method testUpdateUserPermissionManageRole.

@Test
public void testUpdateUserPermissionManageRole() {
    String name = "testUpdateUserPermissionNoRole";
    String code = "testUpdateUserPermissionNoRole_code";
    Organization organization = new JsonOrganization(code, name, "a", "b", null, null);
    organizationFacade.createOrganization(organization);
    organizationFacade.updateUserPermissions(code, new JsonPermission(userEmail, Role.toStringRoles(new HashSet<>(Arrays.asList(Role.READ, Role.MANAGE)))));
    Permission newPermission = new JsonPermission(userEmail, Role.toStringRoles(new HashSet<>(Collections.singletonList(Role.WRITE))));
    Response response = client.target(TARGET_URI).path(PATH_PREFIX + code + "/permissions/users").request(MediaType.APPLICATION_JSON).buildPut(Entity.json(newPermission)).invoke();
    assertThat(response.getStatusInfo()).isEqualTo(Response.Status.OK);
}
Also used : Response(javax.ws.rs.core.Response) Organization(io.lumeer.api.model.Organization) JsonOrganization(io.lumeer.api.dto.JsonOrganization) JsonPermission(io.lumeer.api.dto.JsonPermission) Permission(io.lumeer.api.model.Permission) JsonOrganization(io.lumeer.api.dto.JsonOrganization) JsonPermission(io.lumeer.api.dto.JsonPermission) Test(org.junit.Test)

Example 7 with JsonPermission

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

the class OrganizationServicePermissionsIT method testUpdateUserPermissionNoRole.

@Test
public void testUpdateUserPermissionNoRole() {
    String name = "testUpdateUserPermissionNoRole";
    String code = "testUpdateUserPermissionNoRole_code";
    Organization organization = new JsonOrganization(code, name, "a", "b", null, null);
    organizationFacade.createOrganization(organization);
    organizationFacade.removeUserPermission(code, userEmail);
    Permission newPermission = new JsonPermission(userEmail, Role.toStringRoles(new HashSet<>(Collections.singletonList(Role.WRITE))));
    Response response = client.target(TARGET_URI).path(PATH_PREFIX + code + "/permissions/users").request(MediaType.APPLICATION_JSON).buildPut(Entity.json(newPermission)).invoke();
    assertThat(response.getStatusInfo()).isEqualTo(Response.Status.UNAUTHORIZED);
}
Also used : Response(javax.ws.rs.core.Response) Organization(io.lumeer.api.model.Organization) JsonOrganization(io.lumeer.api.dto.JsonOrganization) JsonPermission(io.lumeer.api.dto.JsonPermission) Permission(io.lumeer.api.model.Permission) JsonOrganization(io.lumeer.api.dto.JsonOrganization) JsonPermission(io.lumeer.api.dto.JsonPermission) Test(org.junit.Test)

Example 8 with JsonPermission

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

the class OrganizationServicePermissionsIT method testRemoveGroupPermissionManageRole.

@Test
public void testRemoveGroupPermissionManageRole() {
    String name = "testRemoveGroupPermissionNoRole";
    String code = "testRemoveGroupPermissionNoRole_code";
    Organization organization = new JsonOrganization(code, name, "a", "b", null, null);
    organizationFacade.createOrganization(organization);
    organizationFacade.updateUserPermissions(code, new JsonPermission(userEmail, Role.toStringRoles(new HashSet<>(Arrays.asList(Role.READ, Role.MANAGE)))));
    String group = "testGroup3";
    Response response = client.target(TARGET_URI).path(PATH_PREFIX + code + "/permissions/groups/" + group).request(MediaType.APPLICATION_JSON).buildDelete().invoke();
    assertThat(response.getStatusInfo()).isEqualTo(Response.Status.OK);
}
Also used : Response(javax.ws.rs.core.Response) Organization(io.lumeer.api.model.Organization) JsonOrganization(io.lumeer.api.dto.JsonOrganization) JsonOrganization(io.lumeer.api.dto.JsonOrganization) JsonPermission(io.lumeer.api.dto.JsonPermission) Test(org.junit.Test)

Example 9 with JsonPermission

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

the class ProjectServicePermissionsIT method testUpdateGroupPermissionsNoRole.

@Test
public void testUpdateGroupPermissionsNoRole() {
    String projectCode = "testGetProjectPermissionsNoRole_code1";
    String projectName = "testGetProjectPermissionsNoRole";
    createProject(projectCode, projectName);
    projectFacade.removeUserPermission(projectCode, userEmail);
    String group = "testGroup4";
    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.UNAUTHORIZED);
}
Also used : Response(javax.ws.rs.core.Response) JsonPermission(io.lumeer.api.dto.JsonPermission) MorphiaPermission(io.lumeer.storage.mongodb.model.embedded.MorphiaPermission) SimplePermission(io.lumeer.core.model.SimplePermission) Permission(io.lumeer.api.model.Permission) JsonPermission(io.lumeer.api.dto.JsonPermission) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 10 with JsonPermission

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

the class ProjectServicePermissionsIT method testUpdateUserPermissionsNoRole.

@Test
public void testUpdateUserPermissionsNoRole() {
    String projectCode = "testGetProjectPermissionsNoRole_code1";
    String projectName = "testGetProjectPermissionsNoRole";
    createProject(projectCode, projectName);
    projectFacade.removeUserPermission(projectCode, userEmail);
    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.UNAUTHORIZED);
}
Also used : Response(javax.ws.rs.core.Response) JsonPermission(io.lumeer.api.dto.JsonPermission) MorphiaPermission(io.lumeer.storage.mongodb.model.embedded.MorphiaPermission) SimplePermission(io.lumeer.core.model.SimplePermission) Permission(io.lumeer.api.model.Permission) JsonPermission(io.lumeer.api.dto.JsonPermission) HashSet(java.util.HashSet) Test(org.junit.Test)

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