use of io.lumeer.api.model.Permission in project engine by Lumeer.
the class ProjectServicePermissionsIT method testUpdateGroupPermissionsNoRole.
@Test
public void testUpdateGroupPermissionsNoRole() {
String projectCode = "testGetProjectPermissionsNoRole_code1";
String projectName = "testGetProjectPermissionsNoRole";
createProject(projectCode, projectName);
projectFacade.removeUserPermission(projectCode, userEmail);
String group = "testGroup4";
Permission newPermission = new JsonPermission(group, Role.toStringRoles(new HashSet<>(Arrays.asList(Role.WRITE))));
Response response = client.target(TARGET_URI).path(PATH_PREFIX + projectCode + "/permissions/groups").request(MediaType.APPLICATION_JSON).buildPut(Entity.json(newPermission)).invoke();
assertThat(response.getStatusInfo()).isEqualTo(Response.Status.UNAUTHORIZED);
}
use of io.lumeer.api.model.Permission in project engine by Lumeer.
the class ProjectServicePermissionsIT method testUpdateUserPermissionsNoRole.
@Test
public void testUpdateUserPermissionsNoRole() {
String projectCode = "testGetProjectPermissionsNoRole_code1";
String projectName = "testGetProjectPermissionsNoRole";
createProject(projectCode, projectName);
projectFacade.removeUserPermission(projectCode, userEmail);
Permission newPermission = new JsonPermission(userEmail, Role.toStringRoles(new HashSet<>(Arrays.asList(Role.WRITE))));
Response response = client.target(TARGET_URI).path(PATH_PREFIX + projectCode + "/permissions/users").request(MediaType.APPLICATION_JSON).buildPut(Entity.json(newPermission)).invoke();
assertThat(response.getStatusInfo()).isEqualTo(Response.Status.UNAUTHORIZED);
}
use of io.lumeer.api.model.Permission in project engine by Lumeer.
the class AbstractFacade method keepOnlyActualUserRoles.
protected <T extends Resource> T keepOnlyActualUserRoles(final T resource) {
Set<Role> roles = permissionsChecker.getActualRoles(resource);
Permission permission = new SimplePermission(authenticatedUser.getUserEmail(), roles);
resource.getPermissions().clear();
resource.getPermissions().updateUserPermissions(permission);
return resource;
}
use of io.lumeer.api.model.Permission 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();
}
use of io.lumeer.api.model.Permission 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();
}
Aggregations