Search in sources :

Example 41 with Permissions

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

the class OrganizationFacadeIT method testGetOrganizationPermissions.

@Test
public void testGetOrganizationPermissions() {
    createOrganization(CODE1);
    createOrganizationWithReadOnlyPermissions(CODE2);
    createOrganizationWithStrangerPermissions(CODE3);
    Permissions permissions = organizationFacade.getOrganizationPermissions(CODE1);
    assertThat(permissions).isNotNull();
    assertPermissions(permissions.getUserPermissions(), USER_PERMISSION);
    assertPermissions(permissions.getGroupPermissions(), GROUP_PERMISSION);
    permissions = organizationFacade.getOrganizationPermissions(CODE2);
    assertThat(permissions).isNotNull();
    assertPermissions(permissions.getUserPermissions(), USER_READONLY_PERMISSION);
    permissions = organizationFacade.getOrganizationPermissions(CODE3);
    assertThat(permissions).isNotNull();
    assertThat(permissions.getUserPermissions()).hasSize(2).contains(USER_PERMISSION, STRANGER_PERMISSION);
}
Also used : Permissions(io.lumeer.api.model.Permissions) LumeerAssertions.assertPermissions(io.lumeer.test.util.LumeerAssertions.assertPermissions) Test(org.junit.Test)

Example 42 with Permissions

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

the class OrganizationFacadeIT method testUpdateUserPermissions.

@Test
public void testUpdateUserPermissions() {
    createOrganization(CODE1);
    SimplePermission userPermission = new SimplePermission(USER, new HashSet<>(Arrays.asList(Role.MANAGE, Role.READ)));
    organizationFacade.updateUserPermissions(CODE1, userPermission);
    Permissions permissions = organizationDao.getOrganizationByCode(CODE1).getPermissions();
    assertThat(permissions).isNotNull();
    assertPermissions(permissions.getUserPermissions(), userPermission);
    assertPermissions(permissions.getGroupPermissions(), GROUP_PERMISSION);
}
Also used : Permissions(io.lumeer.api.model.Permissions) LumeerAssertions.assertPermissions(io.lumeer.test.util.LumeerAssertions.assertPermissions) SimplePermission(io.lumeer.core.model.SimplePermission) Test(org.junit.Test)

Example 43 with Permissions

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

the class OrganizationFacadeIT method testUpdateGroupPermissions.

@Test
public void testUpdateGroupPermissions() {
    createOrganization(CODE1);
    SimplePermission groupPermission = new SimplePermission(GROUP, new HashSet<>(Arrays.asList(Role.SHARE, Role.READ)));
    organizationFacade.updateGroupPermissions(CODE1, groupPermission);
    Permissions permissions = organizationDao.getOrganizationByCode(CODE1).getPermissions();
    assertThat(permissions).isNotNull();
    assertPermissions(permissions.getUserPermissions(), USER_PERMISSION);
    assertPermissions(permissions.getGroupPermissions(), groupPermission);
}
Also used : Permissions(io.lumeer.api.model.Permissions) LumeerAssertions.assertPermissions(io.lumeer.test.util.LumeerAssertions.assertPermissions) SimplePermission(io.lumeer.core.model.SimplePermission) Test(org.junit.Test)

Example 44 with Permissions

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

the class ProjectFacadeIT method testUpdateGroupPermissions.

@Test
public void testUpdateGroupPermissions() {
    createProject(CODE1);
    SimplePermission groupPermission = new SimplePermission(GROUP, new HashSet<>(Arrays.asList(Role.SHARE, Role.READ)));
    projectFacade.updateGroupPermissions(CODE1, groupPermission);
    Permissions permissions = projectDao.getProjectByCode(CODE1).getPermissions();
    Assertions.assertThat(permissions).isNotNull();
    assertPermissions(permissions.getUserPermissions(), USER_PERMISSION);
    assertPermissions(permissions.getGroupPermissions(), groupPermission);
}
Also used : LumeerAssertions.assertPermissions(io.lumeer.test.util.LumeerAssertions.assertPermissions) MorphiaPermissions(io.lumeer.storage.mongodb.model.embedded.MorphiaPermissions) Permissions(io.lumeer.api.model.Permissions) SimplePermission(io.lumeer.core.model.SimplePermission) Test(org.junit.Test)

Example 45 with Permissions

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

the class ProjectFacadeIT method testUpdateUserPermissions.

@Test
public void testUpdateUserPermissions() {
    createProject(CODE1);
    SimplePermission userPermission = new SimplePermission(USER, new HashSet<>(Arrays.asList(Role.MANAGE, Role.READ)));
    projectFacade.updateUserPermissions(CODE1, userPermission);
    Permissions permissions = projectDao.getProjectByCode(CODE1).getPermissions();
    Assertions.assertThat(permissions).isNotNull();
    assertPermissions(permissions.getUserPermissions(), userPermission);
    assertPermissions(permissions.getGroupPermissions(), GROUP_PERMISSION);
}
Also used : LumeerAssertions.assertPermissions(io.lumeer.test.util.LumeerAssertions.assertPermissions) MorphiaPermissions(io.lumeer.storage.mongodb.model.embedded.MorphiaPermissions) Permissions(io.lumeer.api.model.Permissions) SimplePermission(io.lumeer.core.model.SimplePermission) Test(org.junit.Test)

Aggregations

Permissions (io.lumeer.api.model.Permissions)45 LumeerAssertions.assertPermissions (io.lumeer.test.util.LumeerAssertions.assertPermissions)44 Test (org.junit.Test)44 JsonPermissions (io.lumeer.api.dto.JsonPermissions)29 Response (javax.ws.rs.core.Response)24 MorphiaPermissions (io.lumeer.storage.mongodb.model.embedded.MorphiaPermissions)22 SimplePermission (io.lumeer.core.model.SimplePermission)20 JsonPermission (io.lumeer.api.dto.JsonPermission)12 HashSet (java.util.HashSet)12 Set (java.util.Set)12 Entity (javax.ws.rs.client.Entity)12 Permission (io.lumeer.api.model.Permission)5 Resource (io.lumeer.api.model.Resource)5 Organization (io.lumeer.api.model.Organization)4 Role (io.lumeer.api.model.Role)4 AuthenticatedUser (io.lumeer.core.AuthenticatedUser)4 OrganizationDao (io.lumeer.storage.api.dao.OrganizationDao)4 ResourceNotFoundException (io.lumeer.storage.api.exception.ResourceNotFoundException)4 Arrays (java.util.Arrays)4 Collections (java.util.Collections)4