use of io.lumeer.api.model.Permissions in project engine by Lumeer.
the class OrganizationFacadeIT method testRemoveUserPermission.
@Test
public void testRemoveUserPermission() {
createOrganization(CODE1);
organizationFacade.removeUserPermission(CODE1, USER);
Permissions permissions = organizationDao.getOrganizationByCode(CODE1).getPermissions();
assertThat(permissions).isNotNull();
assertThat(permissions.getUserPermissions()).isEmpty();
assertPermissions(permissions.getGroupPermissions(), GROUP_PERMISSION);
}
use of io.lumeer.api.model.Permissions in project engine by Lumeer.
the class ProjectFacadeIT method testRemoveGroupPermission.
@Test
public void testRemoveGroupPermission() {
createProject(CODE1);
projectFacade.removeGroupPermission(CODE1, GROUP);
Permissions permissions = projectDao.getProjectByCode(CODE1).getPermissions();
Assertions.assertThat(permissions).isNotNull();
assertPermissions(permissions.getUserPermissions(), USER_PERMISSION);
Assertions.assertThat(permissions.getGroupPermissions()).isEmpty();
}
use of io.lumeer.api.model.Permissions in project engine by Lumeer.
the class ProjectFacadeIT method testRemoveUserPermission.
@Test
public void testRemoveUserPermission() {
createProject(CODE1);
projectFacade.removeUserPermission(CODE1, USER);
Permissions permissions = projectDao.getProjectByCode(CODE1).getPermissions();
Assertions.assertThat(permissions).isNotNull();
Assertions.assertThat(permissions.getUserPermissions()).isEmpty();
assertPermissions(permissions.getGroupPermissions(), GROUP_PERMISSION);
}
use of io.lumeer.api.model.Permissions in project engine by Lumeer.
the class OrganizationServiceIT method testUpdateUserPermissions.
@Test
public void testUpdateUserPermissions() {
createOrganizationWithSpecificPermissions(CODE1);
SimplePermission userPermission = new SimplePermission(USER, new HashSet<>(Arrays.asList(Role.MANAGE, Role.READ)));
Entity entity = Entity.json(userPermission);
Response response = client.target(PERMISSIONS_URL).path("users").request(MediaType.APPLICATION_JSON).buildPut(entity).invoke();
assertThat(response).isNotNull();
assertThat(response.getStatusInfo()).isEqualTo(Response.Status.OK);
Set<JsonPermission> returnedPermissions = response.readEntity(new GenericType<Set<JsonPermission>>() {
});
assertThat(returnedPermissions).isNotNull().hasSize(1);
assertPermissions(Collections.unmodifiableSet(returnedPermissions), userPermission);
Permissions storedPermissions = organizationDao.getOrganizationByCode(CODE1).getPermissions();
assertThat(storedPermissions).isNotNull();
assertPermissions(storedPermissions.getUserPermissions(), userPermission);
assertPermissions(storedPermissions.getGroupPermissions(), GROUP_PERMISSION);
}
use of io.lumeer.api.model.Permissions in project engine by Lumeer.
the class OrganizationServiceIT method testGetOrganizations.
@Test
public void testGetOrganizations() {
createOrganization(CODE1);
createOrganization(CODE2);
Response response = client.target(ORGANIZATION_URL).request(MediaType.APPLICATION_JSON).buildGet().invoke();
assertThat(response).isNotNull();
assertThat(response.getStatusInfo()).isEqualTo(Response.Status.OK);
List<JsonOrganization> organizations = response.readEntity(new GenericType<List<JsonOrganization>>() {
});
assertThat(organizations).extracting(Resource::getCode).containsOnly(CODE1, CODE2);
Permissions permissions1 = organizations.get(0).getPermissions();
assertThat(permissions1).extracting(Permissions::getUserPermissions).containsOnly(Collections.singleton(USER_PERMISSION));
assertThat(permissions1).extracting(p -> p.getUserPermissions().iterator().next().getRoles()).containsOnly(USER_ROLES);
assertThat(permissions1).extracting(Permissions::getGroupPermissions).containsOnly(Collections.emptySet());
Permissions permissions2 = organizations.get(1).getPermissions();
assertThat(permissions2).extracting(Permissions::getUserPermissions).containsOnly(Collections.singleton(USER_PERMISSION));
assertThat(permissions2).extracting(p -> p.getUserPermissions().iterator().next().getRoles()).containsOnly(USER_ROLES);
assertThat(permissions2).extracting(Permissions::getGroupPermissions).containsOnly(Collections.emptySet());
}
Aggregations