use of io.lumeer.api.model.Permissions in project engine by Lumeer.
the class ProjectServiceIT method testUpdateUserPermissions.
@Test
public void testUpdateUserPermissions() {
createProject(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 = projectDao.getProjectByCode(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 ViewServiceIT method testGetViewPermissions.
@Test
public void testGetViewPermissions() {
createView(CODE);
Response response = client.target(PERMISSIONS_URL).request(MediaType.APPLICATION_JSON).buildGet().invoke();
assertThat(response).isNotNull();
assertThat(response.getStatusInfo()).isEqualTo(Response.Status.OK);
Permissions permissions = response.readEntity(JsonPermissions.class);
assertPermissions(permissions.getUserPermissions(), USER_PERMISSION);
assertPermissions(permissions.getGroupPermissions(), GROUP_PERMISSION);
}
use of io.lumeer.api.model.Permissions in project engine by Lumeer.
the class ViewServiceIT method testUpdateUserPermissions.
@Test
public void testUpdateUserPermissions() {
createView(CODE);
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 = viewDao.getViewByCode(CODE).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 ProjectFacadeIT method testGetProjectPermissions.
@Test
public void testGetProjectPermissions() {
createProject(CODE1);
createProjectWithReadOnlyPermissions(CODE2);
createProjectWithStrangerPermissions(CODE3);
Permissions permissions = projectFacade.getProjectPermissions(CODE1);
assertThat(permissions).isNotNull();
assertPermissions(permissions.getUserPermissions(), USER_PERMISSION);
assertPermissions(permissions.getGroupPermissions(), GROUP_PERMISSION);
permissions = projectFacade.getProjectPermissions(CODE2);
assertThat(permissions).isNotNull();
assertPermissions(permissions.getUserPermissions(), USER_READONLY_PERMISSION);
permissions = projectFacade.getProjectPermissions(CODE3);
assertThat(permissions).isNotNull();
assertThat(permissions.getUserPermissions()).hasSize(2).contains(USER_PERMISSION, STRANGER_PERMISSION);
}
use of io.lumeer.api.model.Permissions in project engine by Lumeer.
the class ViewFacadeIT method testUpdateGroupPermissions.
@Test
public void testUpdateGroupPermissions() {
createView(CODE);
SimplePermission groupPermission = new SimplePermission(GROUP, new HashSet<>(Arrays.asList(Role.SHARE, Role.READ)));
viewFacade.updateGroupPermissions(CODE, groupPermission);
Permissions permissions = viewDao.getViewByCode(CODE).getPermissions();
assertThat(permissions).isNotNull();
assertPermissions(permissions.getUserPermissions(), USER_PERMISSION);
assertPermissions(permissions.getGroupPermissions(), groupPermission);
}
Aggregations