Search in sources :

Example 26 with Organization

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

the class OrganizationServicePermissionsIT method testRemoveGroupPermissionNoRole.

@Test
public void testRemoveGroupPermissionNoRole() {
    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 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.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 27 with Organization

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

the class OrganizationServicePermissionsIT method testRemoveUserPermissionNoRole.

@Test
public void testRemoveUserPermissionNoRole() {
    String name = "testRemoveUserPermissionNoRole";
    String code = "testRemoveUserPermissionNoRole_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/users/" + userEmail).request(MediaType.APPLICATION_JSON).buildDelete().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 28 with Organization

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

the class ViewFacadeIT method configureProject.

@Before
public void configureProject() {
    MorphiaOrganization organization = new MorphiaOrganization();
    organization.setCode(ORGANIZATION_CODE);
    organization.setPermissions(new MorphiaPermissions());
    Organization storedOrganization = organizationDao.createOrganization(organization);
    projectDao.setOrganization(storedOrganization);
    workspaceKeeper.setWorkspace(ORGANIZATION_CODE, PROJECT_CODE);
    User user = new User(USER);
    userDao.createUser(user);
    MorphiaProject project = new MorphiaProject();
    project.setCode(PROJECT_CODE);
    project.setPermissions(new MorphiaPermissions());
    Project storedProject = projectDao.createProject(project);
    viewDao.setProject(storedProject);
}
Also used : MorphiaProject(io.lumeer.storage.mongodb.model.MorphiaProject) Project(io.lumeer.api.model.Project) Organization(io.lumeer.api.model.Organization) MorphiaOrganization(io.lumeer.storage.mongodb.model.MorphiaOrganization) User(io.lumeer.api.model.User) AuthenticatedUser(io.lumeer.core.AuthenticatedUser) MorphiaOrganization(io.lumeer.storage.mongodb.model.MorphiaOrganization) MorphiaProject(io.lumeer.storage.mongodb.model.MorphiaProject) MorphiaPermissions(io.lumeer.storage.mongodb.model.embedded.MorphiaPermissions) Before(org.junit.Before)

Example 29 with Organization

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

the class OrganizationFacade method deleteOrganization.

public void deleteOrganization(final String organizationCode) {
    Organization organization = organizationDao.getOrganizationByCode(organizationCode);
    permissionsChecker.checkRole(organization, Role.MANAGE);
    deleteOrganizationScopedRepositories(organization);
    organizationDao.deleteOrganization(organization.getId());
}
Also used : Organization(io.lumeer.api.model.Organization)

Example 30 with Organization

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

the class OrganizationFacade method checkRoleAndGetOrganization.

private Organization checkRoleAndGetOrganization(final String organizationCode, final Role role) {
    Organization organization = organizationDao.getOrganizationByCode(organizationCode);
    permissionsChecker.checkRole(organization, role);
    return organization;
}
Also used : Organization(io.lumeer.api.model.Organization)

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