use of io.lumeer.api.model.Resource in project engine by Lumeer.
the class ViewServiceIT method testGetAllViews.
@Test
public void testGetAllViews() {
createView(CODE);
createView(CODE2);
Response response = client.target(VIEWS_URL).request(MediaType.APPLICATION_JSON).buildGet().invoke();
assertThat(response).isNotNull();
assertThat(response.getStatusInfo()).isEqualTo(Response.Status.OK);
List<JsonView> views = response.readEntity(new GenericType<List<JsonView>>() {
});
assertThat(views).extracting(Resource::getCode).containsOnly(CODE, CODE2);
Permissions permissions1 = views.get(0).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());
Permissions permissions2 = views.get(1).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());
}
use of io.lumeer.api.model.Resource in project engine by Lumeer.
the class CollectionServiceIT method testGetAllCollections.
@Test
public void testGetAllCollections() {
createCollection(CODE);
createCollection(CODE2);
Response response = client.target(COLLECTIONS_URL).request(MediaType.APPLICATION_JSON).buildGet().invoke();
assertThat(response).isNotNull();
assertThat(response.getStatusInfo()).isEqualTo(Response.Status.OK);
List<JsonCollection> collections = response.readEntity(new GenericType<List<JsonCollection>>() {
});
assertThat(collections).extracting(Resource::getCode).containsOnly(CODE, CODE2);
Permissions permissions1 = collections.get(0).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());
Permissions permissions2 = collections.get(1).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());
}
use of io.lumeer.api.model.Resource in project engine by Lumeer.
the class PermissionsCheckerTest method testCheckUserRole.
@Test
public void testCheckUserRole() {
Resource resource = prepareResource(Collections.singleton(Role.READ), Collections.emptySet());
permissionsChecker.checkRole(resource, Role.READ);
}
use of io.lumeer.api.model.Resource in project engine by Lumeer.
the class PermissionsCheckerTest method testCheckGroupRole.
@Test
public void testCheckGroupRole() {
Resource resource = prepareResource(Collections.emptySet(), Collections.singleton(Role.READ));
permissionsChecker.checkRole(resource, Role.READ);
}
use of io.lumeer.api.model.Resource 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);
}
Aggregations