Search in sources :

Example 21 with JsonOrganization

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

the class UserServiceIT method configure.

@Before
public void configure() {
    JsonOrganization organization1 = new JsonOrganization();
    organization1.setCode("LMR");
    organization1.setPermissions(new JsonPermissions());
    organization1.getPermissions().updateUserPermissions(new JsonPermission(USER, Role.toStringRoles(new HashSet<>(Arrays.asList(Role.WRITE, Role.READ, Role.MANAGE)))));
    organizationId1 = organizationDao.createOrganization(organization1).getId();
    JsonOrganization organization2 = new JsonOrganization();
    organization2.setCode("MRL");
    organization2.setPermissions(new JsonPermissions());
    organization2.getPermissions().updateUserPermissions(new JsonPermission(USER, Role.toStringRoles(new HashSet<>(Arrays.asList(Role.WRITE, Role.READ, Role.MANAGE)))));
    organizationId2 = organizationDao.createOrganization(organization2).getId();
}
Also used : JsonPermissions(io.lumeer.api.dto.JsonPermissions) JsonOrganization(io.lumeer.api.dto.JsonOrganization) JsonPermission(io.lumeer.api.dto.JsonPermission) Before(org.junit.Before)

Example 22 with JsonOrganization

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

the class OrganizationServicePermissionsIT method testGetOrganizationNoRole.

@Test
public void testGetOrganizationNoRole() {
    String name = "TestGetOrganizationNoRole";
    String code = "TestGetOrganizationNoRole_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).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 23 with JsonOrganization

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

the class OrganizationServicePermissionsIT method testUpdateGroupPermissionManageRole.

@Test
public void testUpdateGroupPermissionManageRole() {
    String name = "testUpdateGroupPermissionNoRole";
    String code = "testUpdateGroupPermissionNoRole_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 = "testGroup2";
    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.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 24 with JsonOrganization

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

the class OrganizationServicePermissionsIT method testUpdateOrganizationNoRole.

@Test
public void testUpdateOrganizationNoRole() {
    String name = "TestUpdateOrganizationNoRole";
    String code = "TestUpdateOrganizationNoRole_id";
    String newName = "NewTestUpdateOrganizationNoRole";
    Organization organization = new JsonOrganization(code, name, "a", "b", null, null);
    organizationFacade.createOrganization(organization);
    organizationFacade.removeUserPermission(code, userEmail);
    Organization newOrganization = new JsonOrganization(code, newName, "c", "d", null, null);
    Response response = client.target(TARGET_URI).path(PATH_PREFIX + code).request(MediaType.APPLICATION_JSON).buildPut(Entity.json(newOrganization)).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 25 with JsonOrganization

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

the class OrganizationServicePermissionsIT method testCreateProjectInOrganizationNoRole.

@Test
public void testCreateProjectInOrganizationNoRole() {
    String name = "testRemoveGroupPermissionNoRole";
    String code = "testRemoveGroupPermissionNoRole_code";
    Organization organization = new JsonOrganization(code, name, "a", "b", null, null);
    organizationFacade.createOrganization(organization);
    organizationFacade.removeUserPermission(code, userEmail);
    String projectCode = "proj1";
    String projectName = "proj1_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.UNAUTHORIZED);
}
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

JsonOrganization (io.lumeer.api.dto.JsonOrganization)45 Organization (io.lumeer.api.model.Organization)40 JsonPermission (io.lumeer.api.dto.JsonPermission)28 Test (org.junit.Test)23 Response (javax.ws.rs.core.Response)21 JsonPermissions (io.lumeer.api.dto.JsonPermissions)18 Before (org.junit.Before)16 JsonProject (io.lumeer.api.dto.JsonProject)14 Project (io.lumeer.api.model.Project)13 AuthenticatedUser (io.lumeer.core.AuthenticatedUser)13 User (io.lumeer.api.model.User)12 JsonCollection (io.lumeer.api.dto.JsonCollection)8 Permission (io.lumeer.api.model.Permission)6 Role (io.lumeer.api.model.Role)4 SoftAssertions (org.assertj.core.api.SoftAssertions)4 Entity (javax.ws.rs.client.Entity)3 LinkType (io.lumeer.api.model.LinkType)2 SimplePermission (io.lumeer.core.model.SimplePermission)2 List (java.util.List)2 CompanyContact (io.lumeer.api.model.CompanyContact)1