use of io.lumeer.core.model.SimplePermission in project engine by Lumeer.
the class CollectionFacadeIT method testUpdateUserPermissions.
@Test
public void testUpdateUserPermissions() {
String collectionId = createCollection(CODE).getId();
SimplePermission userPermission = new SimplePermission(USER, new HashSet<>(Arrays.asList(Role.MANAGE, Role.READ)));
collectionFacade.updateUserPermissions(collectionId, userPermission);
Permissions permissions = collectionDao.getCollectionByCode(CODE).getPermissions();
assertThat(permissions).isNotNull();
assertPermissions(permissions.getUserPermissions(), userPermission);
assertPermissions(permissions.getGroupPermissions(), GROUP_PERMISSION);
}
use of io.lumeer.core.model.SimplePermission in project engine by Lumeer.
the class OrganizationServiceIT method testUpdateGroupPermissions.
@Test
public void testUpdateGroupPermissions() {
createOrganizationWithSpecificPermissions(CODE1);
SimplePermission groupPermission = new SimplePermission(GROUP, new HashSet<>(Arrays.asList(Role.SHARE, Role.READ)));
Entity entity = Entity.json(groupPermission);
Response response = client.target(PERMISSIONS_URL).path("groups").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), groupPermission);
Permissions storedPermissions = organizationDao.getOrganizationByCode(CODE1).getPermissions();
assertThat(storedPermissions).isNotNull();
assertPermissions(storedPermissions.getUserPermissions(), USER_PERMISSION);
assertPermissions(storedPermissions.getGroupPermissions(), groupPermission);
}
use of io.lumeer.core.model.SimplePermission in project engine by Lumeer.
the class ProjectServiceIT method testUpdateGroupPermissions.
@Test
public void testUpdateGroupPermissions() {
createProject(CODE1);
SimplePermission groupPermission = new SimplePermission(GROUP, new HashSet<>(Arrays.asList(Role.SHARE, Role.READ)));
Entity entity = Entity.json(groupPermission);
Response response = client.target(PERMISSIONS_URL).path("groups").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), groupPermission);
Permissions storedPermissions = projectDao.getProjectByCode(CODE1).getPermissions();
assertThat(storedPermissions).isNotNull();
assertPermissions(storedPermissions.getUserPermissions(), USER_PERMISSION);
assertPermissions(storedPermissions.getGroupPermissions(), groupPermission);
}
use of io.lumeer.core.model.SimplePermission 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.core.model.SimplePermission 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);
}
Aggregations