Search in sources :

Example 1 with MorphiaPermission

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();
}
Also used : SearchQuery(io.lumeer.storage.api.query.SearchQuery) MorphiaPermission(io.lumeer.storage.mongodb.model.embedded.MorphiaPermission) MorphiaPermission(io.lumeer.storage.mongodb.model.embedded.MorphiaPermission) Permission(io.lumeer.api.model.Permission) JsonView(io.lumeer.api.dto.JsonView) JsonView(io.lumeer.api.dto.JsonView) View(io.lumeer.api.model.View) Test(org.junit.Test)

Example 2 with MorphiaPermission

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();
}
Also used : MorphiaOrganization(io.lumeer.storage.mongodb.model.MorphiaOrganization) Organization(io.lumeer.api.model.Organization) MorphiaPermission(io.lumeer.storage.mongodb.model.embedded.MorphiaPermission) DatabaseQuery(io.lumeer.storage.api.query.DatabaseQuery) Permission(io.lumeer.api.model.Permission) MorphiaPermission(io.lumeer.storage.mongodb.model.embedded.MorphiaPermission) Test(org.junit.Test)

Example 3 with MorphiaPermission

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);
}
Also used : Organization(io.lumeer.api.model.Organization) MorphiaOrganization(io.lumeer.storage.mongodb.model.MorphiaOrganization) User(io.lumeer.api.model.User) AuthenticatedUser(io.lumeer.core.AuthenticatedUser) MorphiaPermission(io.lumeer.storage.mongodb.model.embedded.MorphiaPermission) MorphiaOrganization(io.lumeer.storage.mongodb.model.MorphiaOrganization) MorphiaPermissions(io.lumeer.storage.mongodb.model.embedded.MorphiaPermissions) Before(org.junit.Before)

Example 4 with MorphiaPermission

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);
}
Also used : Organization(io.lumeer.api.model.Organization) MorphiaOrganization(io.lumeer.storage.mongodb.model.MorphiaOrganization) User(io.lumeer.api.model.User) AuthenticatedUser(io.lumeer.core.AuthenticatedUser) MorphiaPermission(io.lumeer.storage.mongodb.model.embedded.MorphiaPermission) MorphiaOrganization(io.lumeer.storage.mongodb.model.MorphiaOrganization) MorphiaPermissions(io.lumeer.storage.mongodb.model.embedded.MorphiaPermissions) Before(org.junit.Before)

Example 5 with MorphiaPermission

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();
}
Also used : MorphiaProject(io.lumeer.storage.mongodb.model.MorphiaProject) Project(io.lumeer.api.model.Project) MorphiaPermission(io.lumeer.storage.mongodb.model.embedded.MorphiaPermission) DatabaseQuery(io.lumeer.storage.api.query.DatabaseQuery) MorphiaProject(io.lumeer.storage.mongodb.model.MorphiaProject) Permission(io.lumeer.api.model.Permission) MorphiaPermission(io.lumeer.storage.mongodb.model.embedded.MorphiaPermission) Test(org.junit.Test)

Aggregations

MorphiaPermission (io.lumeer.storage.mongodb.model.embedded.MorphiaPermission)9 Permission (io.lumeer.api.model.Permission)6 Test (org.junit.Test)6 Organization (io.lumeer.api.model.Organization)4 SearchQuery (io.lumeer.storage.api.query.SearchQuery)4 MorphiaOrganization (io.lumeer.storage.mongodb.model.MorphiaOrganization)4 User (io.lumeer.api.model.User)3 AuthenticatedUser (io.lumeer.core.AuthenticatedUser)3 MorphiaPermissions (io.lumeer.storage.mongodb.model.embedded.MorphiaPermissions)3 Before (org.junit.Before)3 Collection (io.lumeer.api.model.Collection)2 View (io.lumeer.api.model.View)2 DatabaseQuery (io.lumeer.storage.api.query.DatabaseQuery)2 MorphiaCollection (io.lumeer.storage.mongodb.model.MorphiaCollection)2 JsonOrganization (io.lumeer.api.dto.JsonOrganization)1 JsonView (io.lumeer.api.dto.JsonView)1 Project (io.lumeer.api.model.Project)1 MorphiaProject (io.lumeer.storage.mongodb.model.MorphiaProject)1 MorphiaView (io.lumeer.storage.mongodb.model.MorphiaView)1 HashSet (java.util.HashSet)1