Search in sources :

Example 21 with Organization

use of io.lumeer.api.model.Organization 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 22 with Organization

use of io.lumeer.api.model.Organization 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 23 with Organization

use of io.lumeer.api.model.Organization in project engine by Lumeer.

the class OrganizationServicePermissionsIT method testGetOrganizationPermissionsNoRole.

@Test
public void testGetOrganizationPermissionsNoRole() {
    String name = "testGetOrganizationPermissionsNoRole";
    String code = "testGetOrganizationPermissionsNoRole_code";
    Organization organization = new JsonOrganization(code, name, "a", "b", null, null);
    organizationFacade.createOrganization(organization);
    organizationFacade.removeUserPermission(code, userEmail);
    Response response = client.target(TARGET_URI).path(PATH_PREFIX + code + "/permissions").request(MediaType.APPLICATION_JSON).buildGet().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) JsonOrganization(io.lumeer.api.dto.JsonOrganization) Test(org.junit.Test)

Example 24 with Organization

use of io.lumeer.api.model.Organization 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 25 with Organization

use of io.lumeer.api.model.Organization in project engine by Lumeer.

the class OrganizationServicePermissionsIT method testCreateProjectInOrganizationManageRole.

@Test
public void testCreateProjectInOrganizationManageRole() {
    String name = "testCreateProjectInOrganizationManageRole";
    String code = "testCreateProjectInOrganizationManageRole_code";
    Organization organization = new JsonOrganization(code, name, "a", "b", null, null);
    organizationFacade.createOrganization(organization);
    String projectCode = "proj2";
    String projectName = "proj2_code";
    Project project = new JsonProject(projectCode, projectName, "a", "b", null, null);
    Response response = client.target(TARGET_URI).path(PATH_PREFIX + code + "/projects").request(MediaType.APPLICATION_JSON).buildPost(Entity.json(project)).invoke();
    assertThat(response.getStatusInfo()).isEqualTo(Response.Status.OK);
}
Also used : Response(javax.ws.rs.core.Response) JsonProject(io.lumeer.api.dto.JsonProject) Project(io.lumeer.api.model.Project) Organization(io.lumeer.api.model.Organization) JsonOrganization(io.lumeer.api.dto.JsonOrganization) JsonOrganization(io.lumeer.api.dto.JsonOrganization) JsonProject(io.lumeer.api.dto.JsonProject) Test(org.junit.Test)

Aggregations

Organization (io.lumeer.api.model.Organization)69 JsonOrganization (io.lumeer.api.dto.JsonOrganization)42 Test (org.junit.Test)31 JsonPermission (io.lumeer.api.dto.JsonPermission)22 Response (javax.ws.rs.core.Response)20 Before (org.junit.Before)18 User (io.lumeer.api.model.User)17 AuthenticatedUser (io.lumeer.core.AuthenticatedUser)17 Project (io.lumeer.api.model.Project)15 JsonProject (io.lumeer.api.dto.JsonProject)14 JsonPermissions (io.lumeer.api.dto.JsonPermissions)13 MorphiaOrganization (io.lumeer.storage.mongodb.model.MorphiaOrganization)13 JsonCollection (io.lumeer.api.dto.JsonCollection)8 Permission (io.lumeer.api.model.Permission)7 SoftAssertions (org.assertj.core.api.SoftAssertions)6 MorphiaPermissions (io.lumeer.storage.mongodb.model.embedded.MorphiaPermissions)5 ResourceNotFoundException (io.lumeer.storage.api.exception.ResourceNotFoundException)4 MorphiaPermission (io.lumeer.storage.mongodb.model.embedded.MorphiaPermission)4 Role (io.lumeer.api.model.Role)3 DatabaseQuery (io.lumeer.storage.api.query.DatabaseQuery)3