use of io.lumeer.storage.mongodb.model.embedded.MorphiaPermission in project engine by Lumeer.
the class MorphiaCollectionDaoTest method testGetCollectionsNoReadRole.
@Test
public void testGetCollectionsNoReadRole() {
MorphiaCollection collection = prepareCollection(CODE, NAME);
Permission userPermission = new MorphiaPermission(USER2, Collections.singleton(Role.CLONE.toString()));
collection.getPermissions().updateUserPermissions(userPermission);
datastore.save(collectionDao.databaseCollection(), collection);
MorphiaCollection collection2 = prepareCollection(CODE2, NAME2);
Permission groupPermission = new MorphiaPermission(GROUP2, Collections.singleton(Role.SHARE.toString()));
collection2.getPermissions().updateGroupPermissions(groupPermission);
datastore.save(collectionDao.databaseCollection(), collection2);
SearchQuery query = SearchQuery.createBuilder(USER2).groups(Collections.singleton(GROUP2)).build();
List<Collection> collections = collectionDao.getCollections(query);
assertThat(collections).isEmpty();
}
use of io.lumeer.storage.mongodb.model.embedded.MorphiaPermission in project engine by Lumeer.
the class MorphiaCollectionDaoTest method testGetCollectionsByCollectionIds.
@Test
public void testGetCollectionsByCollectionIds() {
MorphiaCollection collection = prepareCollection(CODE, NAME);
collection.getPermissions().removeUserPermission(USER);
Permission userPermission = new MorphiaPermission(USER2, Collections.singleton(Role.READ.toString()));
collection.getPermissions().updateUserPermissions(userPermission);
datastore.save(collectionDao.databaseCollection(), collection);
MorphiaCollection collection2 = prepareCollection(CODE2, NAME2);
datastore.save(collectionDao.databaseCollection(), collection2);
MorphiaCollection collection3 = prepareCollection(CODE3, NAME3);
datastore.save(collectionDao.databaseCollection(), collection3);
SearchQuery query = SearchQuery.createBuilder(USER).collectionIds(new HashSet<>(Arrays.asList(collection.getId(), collection3.getId()))).build();
List<Collection> views = collectionDao.getCollections(query);
assertThat(views).extracting(Collection::getId).containsOnly(collection3.getId());
}
use of io.lumeer.storage.mongodb.model.embedded.MorphiaPermission in project engine by Lumeer.
the class MorphiaViewDaoTest method testGetViewsNoReadRole.
@Test
public void testGetViewsNoReadRole() {
MorphiaView view = prepareView();
Permission userPermission = new MorphiaPermission(USER2, Collections.singleton(Role.CLONE.toString()));
view.getPermissions().updateUserPermissions(userPermission);
datastore.save(viewDao.databaseCollection(), view);
MorphiaView view2 = prepareView();
view2.setCode(CODE2);
view2.setName(NAME2);
Permission groupPermission = new MorphiaPermission(GROUP2, Collections.singleton(Role.SHARE.toString()));
view2.getPermissions().updateGroupPermissions(groupPermission);
datastore.save(viewDao.databaseCollection(), view2);
SearchQuery query = SearchQuery.createBuilder(USER2).groups(Collections.singleton(GROUP2)).build();
List<View> views = viewDao.getViews(query);
assertThat(views).isEmpty();
}
use of io.lumeer.storage.mongodb.model.embedded.MorphiaPermission in project engine by Lumeer.
the class ProjectServicePermissionsIT method configureProject.
@Before
public void configureProject() {
MorphiaOrganization organization = new MorphiaOrganization();
organization.setCode(organizationCode);
organization.setName(organizationName);
organization.setPermissions(new MorphiaPermissions());
organization.getPermissions().updateUserPermissions(new MorphiaPermission(userEmail, Role.toStringRoles(new HashSet<>(Arrays.asList(Role.WRITE, Role.READ, Role.MANAGE)))));
Organization storedOrganization = organizationDao.createOrganization(organization);
projectDao.setOrganization(storedOrganization);
workspaceKeeper.setOrganization(organizationCode);
User user = new User(userEmail);
userDao.createUser(user);
}
Aggregations