use of io.lumeer.api.model.Group in project engine by Lumeer.
the class OrganizationServiceIT method testRemoveGroupPermission.
@Test
public void testRemoveGroupPermission() {
Organization organization = createOrganizationWithSpecificPermissions(CODE1);
Group group = new Group(GROUP);
groupDao.setOrganization(organization);
this.group = groupDao.createGroup(group);
organization.getPermissions().removeGroupPermission(GROUP);
organization.getPermissions().updateGroupPermissions(new Permission(group.getId(), GROUP_ROLES));
organization = organizationDao.updateOrganization(organization.getId(), organization);
Response response = client.target(organizationUrl).path(organization.getId()).path("permissions").path("groups").path(this.group.getId()).request(MediaType.APPLICATION_JSON).buildDelete().invoke();
assertThat(response).isNotNull();
assertThat(response.getStatusInfo()).isEqualTo(Response.Status.OK);
assertThat(response.getLinks()).extracting(Link::getUri).containsOnly(UriBuilder.fromUri(organizationUrl + "/" + organization.getId() + "/permissions").build());
Permissions permissions = organizationDao.getOrganizationByCode(CODE1).getPermissions();
assertPermissions(permissions.getUserPermissions(), userPermission);
assertThat(permissions.getGroupPermissions()).isEmpty();
}
use of io.lumeer.api.model.Group in project engine by Lumeer.
the class OrganizationFacadeIT method createOrganizationWithGroupPermissions.
private String createOrganizationWithGroupPermissions(final String code, final RoleType roleType) {
Organization organization = new Organization(code, NAME, ICON, COLOR, null, null, null);
Organization storedOrganization = organizationDao.createOrganization(organization);
groupDao.setOrganization(storedOrganization);
group = groupDao.createGroup(new Group(GROUP, Collections.singletonList(user.getId())));
user.setOrganizations(Collections.singleton(storedOrganization.getId()));
user = userDao.updateUser(user.getId(), user);
permissionsChecker.getPermissionAdapter().invalidateUserCache();
groupPermission = Permission.buildWithRoles(this.group.getId(), Collections.singleton(new Role(roleType)));
storedOrganization.getPermissions().updateGroupPermissions(groupPermission);
organizationDao.updateOrganization(storedOrganization.getId(), storedOrganization);
return storedOrganization.getId();
}
use of io.lumeer.api.model.Group in project engine by Lumeer.
the class FunctionFacadeIT method configureProject.
@Before
public void configureProject() {
User user = userDao.createUser(new User(USER));
Organization organization = new Organization();
organization.setCode(ORGANIZATION_CODE);
Permissions organizationPermissions = new Permissions();
userPermission = Permission.buildWithRoles(user.getId(), Organization.ROLES);
organizationPermissions.updateUserPermissions(userPermission);
organization.setPermissions(organizationPermissions);
organization = organizationDao.createOrganization(organization);
projectDao.setOrganization(organization);
groupDao.setOrganization(organization);
Group group = groupDao.createGroup(new Group(GROUP));
userPermission = Permission.buildWithRoles(user.getId(), Collection.ROLES);
groupPermission = Permission.buildWithRoles(group.getId(), Collections.singleton(new Role(RoleType.Read)));
Project project = new Project();
project.setCode(PROJECT_CODE);
Permissions projectPermissions = new Permissions();
projectPermissions.updateUserPermissions(Permission.buildWithRoles(user.getId(), Project.ROLES));
project.setPermissions(projectPermissions);
Project storedProject = projectDao.createProject(project);
workspaceKeeper.setWorkspaceIds(organization.getId(), storedProject.getId());
functionDao.setProject(project);
}
use of io.lumeer.api.model.Group in project engine by Lumeer.
the class GroupFacadeIT method testUpdateGroupNoPermission.
@Test
public void testUpdateGroupNoPermission() {
String groupId = groupFacade.createGroup(new Group(GROUP1)).getId();
setOrganizationWithoutPermissions();
assertThatThrownBy(() -> groupFacade.updateGroup(groupId, new Group(GROUP2))).isInstanceOf(NoResourcePermissionException.class);
}
use of io.lumeer.api.model.Group in project engine by Lumeer.
the class GroupFacadeIT method testCreateGroupNotPermission.
@Test
public void testCreateGroupNotPermission() {
setOrganizationWithoutPermissions();
assertThatThrownBy(() -> groupFacade.createGroup(new Group(GROUP1))).isInstanceOf(NoResourcePermissionException.class);
}
Aggregations