use of io.lumeer.api.model.Permission 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.api.model.Permission 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.api.model.Permission in project engine by Lumeer.
the class PermissionsCodec method encode.
@Override
public void encode(final BsonWriter writer, final JsonPermissions value, final EncoderContext encoderContext) {
Set<Permission> userPermissions = value.getUserPermissions();
Set<Permission> groupPermissions = value.getGroupPermissions();
Document bson = new Document(USER_ROLES, userPermissions).append(GROUP_ROLES, groupPermissions);
documentCodec.encode(writer, bson, encoderContext);
}
use of io.lumeer.api.model.Permission in project engine by Lumeer.
the class OrganizationServicePermissionsIT method testUpdateUserPermissionManageRole.
@Test
public void testUpdateUserPermissionManageRole() {
String name = "testUpdateUserPermissionNoRole";
String code = "testUpdateUserPermissionNoRole_code";
Organization organization = new JsonOrganization(code, name, "a", "b", null, null);
organizationFacade.createOrganization(organization);
organizationFacade.updateUserPermissions(code, new JsonPermission(userEmail, Role.toStringRoles(new HashSet<>(Arrays.asList(Role.READ, Role.MANAGE)))));
Permission newPermission = new JsonPermission(userEmail, Role.toStringRoles(new HashSet<>(Collections.singletonList(Role.WRITE))));
Response response = client.target(TARGET_URI).path(PATH_PREFIX + code + "/permissions/users").request(MediaType.APPLICATION_JSON).buildPut(Entity.json(newPermission)).invoke();
assertThat(response.getStatusInfo()).isEqualTo(Response.Status.OK);
}
use of io.lumeer.api.model.Permission in project engine by Lumeer.
the class OrganizationServicePermissionsIT method testUpdateUserPermissionNoRole.
@Test
public void testUpdateUserPermissionNoRole() {
String name = "testUpdateUserPermissionNoRole";
String code = "testUpdateUserPermissionNoRole_code";
Organization organization = new JsonOrganization(code, name, "a", "b", null, null);
organizationFacade.createOrganization(organization);
organizationFacade.removeUserPermission(code, userEmail);
Permission newPermission = new JsonPermission(userEmail, Role.toStringRoles(new HashSet<>(Collections.singletonList(Role.WRITE))));
Response response = client.target(TARGET_URI).path(PATH_PREFIX + code + "/permissions/users").request(MediaType.APPLICATION_JSON).buildPut(Entity.json(newPermission)).invoke();
assertThat(response.getStatusInfo()).isEqualTo(Response.Status.UNAUTHORIZED);
}
Aggregations