use of io.lumeer.storage.mongodb.model.embedded.MorphiaPermission in project engine by Lumeer.
the class MongoViewDaoTest method testGetViewsNoReadRole.
@Test
public void testGetViewsNoReadRole() {
JsonView view = prepareView();
Permission userPermission = new MorphiaPermission(USER2, Collections.singleton(Role.CLONE.toString()));
view.getPermissions().updateUserPermissions(userPermission);
viewDao.databaseCollection().insertOne(view);
JsonView view2 = prepareView();
view2.setCode(CODE2);
view2.setName(NAME2);
Permission groupPermission = new MorphiaPermission(GROUP2, Collections.singleton(Role.SHARE.toString()));
view2.getPermissions().updateGroupPermissions(groupPermission);
viewDao.databaseCollection().insertOne(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 MorphiaOrganizationDaoTest method testGetOrganizationsNoReadRole.
@Test
public void testGetOrganizationsNoReadRole() {
Organization organization = prepareOrganization(CODE1);
Permission userPermission = new MorphiaPermission(USER2, Collections.singleton(Role.CLONE.toString()));
organization.getPermissions().updateUserPermissions(userPermission);
datastore.save(organization);
Organization organization2 = prepareOrganization(CODE2);
Permission groupPermission = new MorphiaPermission(GROUP2, Collections.singleton(Role.SHARE.toString()));
organization2.getPermissions().updateGroupPermissions(groupPermission);
datastore.save(organization2);
DatabaseQuery query = DatabaseQuery.createBuilder(USER2).groups(Collections.singleton(GROUP2)).build();
List<Organization> organizations = organizationDao.getOrganizations(query);
assertThat(organizations).isEmpty();
}
use of io.lumeer.storage.mongodb.model.embedded.MorphiaPermission in project engine by Lumeer.
the class ProjectFacadeIT method configureProject.
@Before
public void configureProject() {
MorphiaOrganization organization = new MorphiaOrganization();
organization.setCode(ORGANIZATION_CODE);
organization.setPermissions(new MorphiaPermissions());
organization.getPermissions().updateUserPermissions(new MorphiaPermission(USER, Role.toStringRoles(new HashSet<>(Arrays.asList(Role.WRITE, Role.READ, Role.MANAGE)))));
Organization storedOrganization = organizationDao.createOrganization(organization);
projectDao.setOrganization(storedOrganization);
User user = new User(USER);
userDao.createUser(user);
workspaceKeeper.setOrganization(ORGANIZATION_CODE);
}
use of io.lumeer.storage.mongodb.model.embedded.MorphiaPermission in project engine by Lumeer.
the class ProjectServiceIT method configureProject.
@Before
public void configureProject() {
MorphiaOrganization organization = new MorphiaOrganization();
organization.setCode(ORGANIZATION_CODE);
organization.setPermissions(new MorphiaPermissions());
organization.getPermissions().updateUserPermissions(new MorphiaPermission(USER, Role.toStringRoles(new HashSet<>(Arrays.asList(Role.WRITE, Role.READ, Role.MANAGE)))));
Organization storedOrganization = organizationDao.createOrganization(organization);
projectDao.setOrganization(storedOrganization);
User user = new User(USER);
userDao.createUser(user);
}
use of io.lumeer.storage.mongodb.model.embedded.MorphiaPermission in project engine by Lumeer.
the class MorphiaProjectDaoTest method testGetProjectsNoReadRole.
@Test
public void testGetProjectsNoReadRole() {
MorphiaProject project = prepareProject(CODE1);
Permission userPermission = new MorphiaPermission(USER2, Collections.singleton(Role.CLONE.toString()));
project.getPermissions().updateUserPermissions(userPermission);
datastore.save(projectDao.databaseCollection(), project);
MorphiaProject project2 = prepareProject(CODE2);
Permission groupPermission = new MorphiaPermission(GROUP2, Collections.singleton(Role.SHARE.toString()));
project2.getPermissions().updateGroupPermissions(groupPermission);
datastore.save(projectDao.databaseCollection(), project2);
DatabaseQuery query = DatabaseQuery.createBuilder(USER2).groups(Collections.singleton(GROUP2)).build();
List<Project> projects = projectDao.getProjects(query);
assertThat(projects).isEmpty();
}
Aggregations