use of io.lumeer.api.model.Resource 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);
}
use of io.lumeer.api.model.Resource in project engine by Lumeer.
the class PermissionsCheckerTest method testCheckNoRole.
@Test
public void testCheckNoRole() {
Resource resource = prepareResource(Collections.emptySet(), Collections.emptySet());
assertThatThrownBy(() -> permissionsChecker.checkRole(resource, Role.READ)).isInstanceOf(NoPermissionException.class).hasFieldOrPropertyWithValue("resource", resource);
}
use of io.lumeer.api.model.Resource in project engine by Lumeer.
the class ProjectServiceIT method testGetProjects.
@Test
public void testGetProjects() {
createProject(CODE1);
createProject(CODE2);
Response response = client.target(PROJECT_URL).request(MediaType.APPLICATION_JSON).buildGet().invoke();
assertThat(response).isNotNull();
assertThat(response.getStatusInfo()).isEqualTo(Response.Status.OK);
List<JsonProject> projects = response.readEntity(new GenericType<List<JsonProject>>() {
});
assertThat(projects).extracting(Resource::getCode).containsOnly(CODE1, CODE2);
Project project1 = projects.get(0);
assertThat(project1.getName()).isEqualTo(NAME);
assertThat(project1.getIcon()).isEqualTo(ICON);
assertThat(project1.getColor()).isEqualTo(COLOR);
Permissions permissions1 = project1.getPermissions();
assertThat(permissions1).extracting(Permissions::getUserPermissions).containsOnly(Collections.singleton(USER_PERMISSION));
assertThat(permissions1).extracting(p -> p.getUserPermissions().iterator().next().getRoles()).containsOnly(USER_ROLES);
assertThat(permissions1).extracting(Permissions::getGroupPermissions).containsOnly(Collections.emptySet());
Project project2 = projects.get(1);
assertThat(project2.getName()).isEqualTo(NAME);
assertThat(project2.getIcon()).isEqualTo(ICON);
assertThat(project2.getColor()).isEqualTo(COLOR);
Permissions permissions2 = project2.getPermissions();
assertThat(permissions2).extracting(Permissions::getUserPermissions).containsOnly(Collections.singleton(USER_PERMISSION));
assertThat(permissions2).extracting(p -> p.getUserPermissions().iterator().next().getRoles()).containsOnly(USER_ROLES);
assertThat(permissions2).extracting(Permissions::getGroupPermissions).containsOnly(Collections.emptySet());
}
Aggregations