use of io.lumeer.api.model.QueryStem in project engine by Lumeer.
the class ViewServiceIT method configureProject.
@Before
public void configureProject() {
User user = new User(USER);
this.user = userDao.createUser(user);
userPermission = Permission.buildWithRoles(this.user.getId(), USER_ROLES);
Organization organization = new Organization();
organization.setCode(ORGANIZATION_CODE);
organization.setPermissions(new Permissions());
Organization storedOrganization = organizationDao.createOrganization(organization);
this.organization = storedOrganization;
Permissions organizationPermissions = new Permissions();
Permission userPermission = Permission.buildWithRoles(this.user.getId(), Organization.ROLES);
organizationPermissions.updateUserPermissions(userPermission);
storedOrganization.setPermissions(organizationPermissions);
organizationDao.updateOrganization(storedOrganization.getId(), storedOrganization);
projectDao.setOrganization(storedOrganization);
groupDao.setOrganization(storedOrganization);
group = groupDao.createGroup(new Group(GROUP, Collections.singletonList(user.getId())));
groupPermission = Permission.buildWithRoles(group.getId(), GROUP_ROLES);
Project project = new Project();
project.setCode(PROJECT_CODE);
project.setPermissions(new Permissions());
Project storedProject = projectDao.createProject(project);
this.project = storedProject;
Permissions projectPermissions = new Permissions();
Permission userProjectPermission = Permission.buildWithRoles(this.user.getId(), Project.ROLES);
projectPermissions.updateUserPermissions(userProjectPermission);
storedProject.setPermissions(projectPermissions);
storedProject = projectDao.updateProject(storedProject.getId(), storedProject);
workspaceKeeper.setWorkspaceIds(storedOrganization.getId(), storedProject.getId());
viewDao.setProject(storedProject);
Collection collection = collectionFacade.createCollection(new Collection("abc", "abc random", ICON, COLOR, projectPermissions));
collectionFacade.updateUserPermissions(collection.getId(), Set.of(Permission.buildWithRoles(this.user.getId(), Collections.singleton(new Role(RoleType.Read)))));
query = new Query(new QueryStem(collection.getId()));
viewsUrl = projectPath(storedOrganization, storedProject) + "views";
PermissionCheckerUtil.allowGroups();
}
use of io.lumeer.api.model.QueryStem in project engine by Lumeer.
the class ViewServiceIT method testGetViewWithAuthorRights.
@Test
@SuppressWarnings("unchecked")
public void testGetViewWithAuthorRights() {
// non-existing author
final String USER = "aaaaa4444400000000111112";
Permission workspacePermission = new Permission(USER, Collections.singleton(new Role(RoleType.Read)));
organizationFacade.updateUserPermissions(organization.getId(), Set.of(workspacePermission));
projectFacade.updateUserPermissions(project.getId(), Set.of(workspacePermission));
Permission permission = new Permission(USER, Collections.singleton(new Role(RoleType.DataWrite)));
Collection collection = collectionFacade.createCollection(new Collection("cdefg", "abcefg random", ICON, COLOR, new Permissions(new HashSet<>(Collections.singletonList(permission)), Collections.emptySet())));
collectionFacade.updateUserPermissions(collection.getId(), Set.of(Permission.buildWithRoles(USER, Set.of(new Role(RoleType.DataWrite)))));
View view = prepareView(CODE + "3");
view.setQuery(new Query(new QueryStem(collection.getId())));
view.getPermissions().updateUserPermissions(userPermission);
view.getPermissions().updateGroupPermissions(groupPermission);
view.setAuthorId(USER);
view.getPermissions().updateUserPermissions(permission);
viewDao.createView(view);
Response response = client.target(viewsUrl).path(view.getId()).request(MediaType.APPLICATION_JSON).buildGet().invoke();
assertThat(response).isNotNull();
assertThat(response.getStatusInfo()).isEqualTo(Response.Status.OK);
View returnedView = response.readEntity(View.class);
SoftAssertions assertions = new SoftAssertions();
assertions.assertThat(returnedView.getAuthorCollectionsRights()).containsOnly(new HashMap.SimpleEntry<>(collection.getId(), Set.of(RoleType.DataWrite)));
assertions.assertAll();
}
Aggregations