Search in sources :

Example 1 with Role

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

the class PermissionsCheckerTest method testGetActualRolesIntersection.

@Test
public void testGetActualRolesIntersection() {
    Resource resource = prepareResource(Sets.newLinkedHashSet(Role.READ, Role.WRITE), Sets.newLinkedHashSet(Role.READ, Role.SHARE));
    Set<Role> roles = permissionsChecker.getActualRoles(resource);
    assertThat(roles).containsOnly(Role.READ, Role.WRITE, Role.SHARE);
}
Also used : Role(io.lumeer.api.model.Role) Resource(io.lumeer.api.model.Resource) Test(org.junit.Test)

Example 2 with Role

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

the class PermissionsCheckerTest method testGetActualRolesEmpty.

@Test
public void testGetActualRolesEmpty() {
    Resource resource = prepareResource(Collections.emptySet(), Collections.emptySet());
    Set<Role> roles = permissionsChecker.getActualRoles(resource);
    assertThat(roles).isEmpty();
}
Also used : Role(io.lumeer.api.model.Role) Resource(io.lumeer.api.model.Resource) Test(org.junit.Test)

Example 3 with Role

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

the class AbstractFacade method keepOnlyActualUserRoles.

protected <T extends Resource> T keepOnlyActualUserRoles(final T resource) {
    Set<Role> roles = permissionsChecker.getActualRoles(resource);
    Permission permission = new SimplePermission(authenticatedUser.getUserEmail(), roles);
    resource.getPermissions().clear();
    resource.getPermissions().updateUserPermissions(permission);
    return resource;
}
Also used : Role(io.lumeer.api.model.Role) Permission(io.lumeer.api.model.Permission) SimplePermission(io.lumeer.core.model.SimplePermission) SimplePermission(io.lumeer.core.model.SimplePermission)

Example 4 with Role

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

the class PermissionsCheckerTest method testGetActualRolesGroupOnly.

@Test
public void testGetActualRolesGroupOnly() {
    Resource resource = prepareResource(Collections.emptySet(), Sets.newLinkedHashSet(Role.READ, Role.SHARE));
    Set<Role> roles = permissionsChecker.getActualRoles(resource);
    assertThat(roles).containsOnly(Role.READ, Role.SHARE);
}
Also used : Role(io.lumeer.api.model.Role) Resource(io.lumeer.api.model.Resource) Test(org.junit.Test)

Example 5 with Role

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

the class PermissionsCheckerTest method testGetActualRolesUserOnly.

@Test
public void testGetActualRolesUserOnly() {
    Resource resource = prepareResource(Sets.newLinkedHashSet(Role.READ, Role.WRITE), Collections.emptySet());
    Set<Role> roles = permissionsChecker.getActualRoles(resource);
    assertThat(roles).containsOnly(Role.READ, Role.WRITE);
}
Also used : Role(io.lumeer.api.model.Role) Resource(io.lumeer.api.model.Resource) Test(org.junit.Test)

Aggregations

Role (io.lumeer.api.model.Role)8 Test (org.junit.Test)7 Resource (io.lumeer.api.model.Resource)4 JsonOrganization (io.lumeer.api.dto.JsonOrganization)3 JsonPermission (io.lumeer.api.dto.JsonPermission)3 Organization (io.lumeer.api.model.Organization)3 Response (javax.ws.rs.core.Response)3 Permission (io.lumeer.api.model.Permission)1 SimplePermission (io.lumeer.core.model.SimplePermission)1