use of io.lumeer.api.model.Permissions in project engine by Lumeer.
the class OrganizationServiceIT method testGetOrganizationPermissions.
@Test
public void testGetOrganizationPermissions() {
createOrganizationWithSpecificPermissions(CODE1);
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 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.api.model.Permissions in project engine by Lumeer.
the class OrganizationServiceIT method testRemoveGroupPermission.
@Test
public void testRemoveGroupPermission() {
createOrganizationWithSpecificPermissions(CODE1);
Response response = client.target(PERMISSIONS_URL).path("groups").path(GROUP).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(PERMISSIONS_URL).build());
Permissions permissions = organizationDao.getOrganizationByCode(CODE1).getPermissions();
assertPermissions(permissions.getUserPermissions(), USER_PERMISSION);
assertThat(permissions.getGroupPermissions()).isEmpty();
}
use of io.lumeer.api.model.Permissions 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.api.model.Permissions in project engine by Lumeer.
the class ProjectServiceIT method testGetProjects.
@Test
public void testGetProjects() {
createProject(CODE1);
createProject(CODE2);
Response response = client.target(PROJECT_URL).request(MediaType.APPLICATION_JSON).buildGet().invoke();
assertThat(response).isNotNull();
assertThat(response.getStatusInfo()).isEqualTo(Response.Status.OK);
List<JsonProject> projects = response.readEntity(new GenericType<List<JsonProject>>() {
});
assertThat(projects).extracting(Resource::getCode).containsOnly(CODE1, CODE2);
Project project1 = projects.get(0);
assertThat(project1.getName()).isEqualTo(NAME);
assertThat(project1.getIcon()).isEqualTo(ICON);
assertThat(project1.getColor()).isEqualTo(COLOR);
Permissions permissions1 = project1.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());
Project project2 = projects.get(1);
assertThat(project2.getName()).isEqualTo(NAME);
assertThat(project2.getIcon()).isEqualTo(ICON);
assertThat(project2.getColor()).isEqualTo(COLOR);
Permissions permissions2 = project2.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