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);
}
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();
}
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;
}
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);
}
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);
}
Aggregations