Search in sources :

Example 36 with Permissions

use of io.lumeer.api.model.Permissions in project engine by Lumeer.

the class ViewFacadeIT method testUpdateUserPermissions.

@Test
public void testUpdateUserPermissions() {
    createView(CODE);
    SimplePermission userPermission = new SimplePermission(USER, new HashSet<>(Arrays.asList(Role.MANAGE, Role.READ)));
    viewFacade.updateUserPermissions(CODE, userPermission);
    Permissions permissions = viewDao.getViewByCode(CODE).getPermissions();
    assertThat(permissions).isNotNull();
    assertPermissions(permissions.getUserPermissions(), userPermission);
    assertPermissions(permissions.getGroupPermissions(), GROUP_PERMISSION);
}
Also used : LumeerAssertions.assertPermissions(io.lumeer.test.util.LumeerAssertions.assertPermissions) MorphiaPermissions(io.lumeer.storage.mongodb.model.embedded.MorphiaPermissions) Permissions(io.lumeer.api.model.Permissions) SimplePermission(io.lumeer.core.model.SimplePermission) Test(org.junit.Test)

Example 37 with Permissions

use of io.lumeer.api.model.Permissions in project engine by Lumeer.

the class ViewFacadeIT method testGetViewPermissions.

@Test
public void testGetViewPermissions() {
    createView(CODE);
    Permissions permissions = viewFacade.getViewPermissions(CODE);
    assertThat(permissions).isNotNull();
    assertPermissions(permissions.getUserPermissions(), USER_PERMISSION);
    assertPermissions(permissions.getGroupPermissions(), GROUP_PERMISSION);
}
Also used : LumeerAssertions.assertPermissions(io.lumeer.test.util.LumeerAssertions.assertPermissions) MorphiaPermissions(io.lumeer.storage.mongodb.model.embedded.MorphiaPermissions) Permissions(io.lumeer.api.model.Permissions) Test(org.junit.Test)

Example 38 with Permissions

use of io.lumeer.api.model.Permissions in project engine by Lumeer.

the class CollectionServiceIT method testRemoveUserPermission.

@Test
public void testRemoveUserPermission() {
    String collectionId = createCollection(CODE).getId();
    Response response = client.target(COLLECTIONS_URL).path(collectionId).path("permissions").path("users").path(USER).request(MediaType.APPLICATION_JSON).buildDelete().invoke();
    assertThat(response).isNotNull();
    assertThat(response.getStatusInfo()).isEqualTo(Response.Status.OK);
    Permissions permissions = collectionDao.getCollectionByCode(CODE).getPermissions();
    assertThat(permissions.getUserPermissions()).isEmpty();
    assertPermissions(permissions.getGroupPermissions(), GROUP_PERMISSION);
}
Also used : Response(javax.ws.rs.core.Response) LumeerAssertions.assertPermissions(io.lumeer.test.util.LumeerAssertions.assertPermissions) JsonPermissions(io.lumeer.api.dto.JsonPermissions) Permissions(io.lumeer.api.model.Permissions) Test(org.junit.Test)

Example 39 with Permissions

use of io.lumeer.api.model.Permissions in project engine by Lumeer.

the class CollectionServiceIT method testRemoveGroupPermission.

@Test
public void testRemoveGroupPermission() {
    String collectionId = createCollection(CODE).getId();
    Response response = client.target(COLLECTIONS_URL).path(collectionId).path("permissions").path("groups").path(GROUP).request(MediaType.APPLICATION_JSON).buildDelete().invoke();
    assertThat(response).isNotNull();
    assertThat(response.getStatusInfo()).isEqualTo(Response.Status.OK);
    Permissions permissions = collectionDao.getCollectionByCode(CODE).getPermissions();
    assertPermissions(permissions.getUserPermissions(), USER_PERMISSION);
    assertThat(permissions.getGroupPermissions()).isEmpty();
}
Also used : Response(javax.ws.rs.core.Response) LumeerAssertions.assertPermissions(io.lumeer.test.util.LumeerAssertions.assertPermissions) JsonPermissions(io.lumeer.api.dto.JsonPermissions) Permissions(io.lumeer.api.model.Permissions) Test(org.junit.Test)

Example 40 with Permissions

use of io.lumeer.api.model.Permissions in project engine by Lumeer.

the class CollectionServiceIT method testGetCollectionPermissions.

@Test
public void testGetCollectionPermissions() {
    String collectionId = createCollection(CODE).getId();
    Response response = client.target(COLLECTIONS_URL).path(collectionId).path("permissions").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);
}
Also used : Response(javax.ws.rs.core.Response) LumeerAssertions.assertPermissions(io.lumeer.test.util.LumeerAssertions.assertPermissions) JsonPermissions(io.lumeer.api.dto.JsonPermissions) Permissions(io.lumeer.api.model.Permissions) Test(org.junit.Test)

Aggregations

Permissions (io.lumeer.api.model.Permissions)45 LumeerAssertions.assertPermissions (io.lumeer.test.util.LumeerAssertions.assertPermissions)44 Test (org.junit.Test)44 JsonPermissions (io.lumeer.api.dto.JsonPermissions)29 Response (javax.ws.rs.core.Response)24 MorphiaPermissions (io.lumeer.storage.mongodb.model.embedded.MorphiaPermissions)22 SimplePermission (io.lumeer.core.model.SimplePermission)20 JsonPermission (io.lumeer.api.dto.JsonPermission)12 HashSet (java.util.HashSet)12 Set (java.util.Set)12 Entity (javax.ws.rs.client.Entity)12 Permission (io.lumeer.api.model.Permission)5 Resource (io.lumeer.api.model.Resource)5 Organization (io.lumeer.api.model.Organization)4 Role (io.lumeer.api.model.Role)4 AuthenticatedUser (io.lumeer.core.AuthenticatedUser)4 OrganizationDao (io.lumeer.storage.api.dao.OrganizationDao)4 ResourceNotFoundException (io.lumeer.storage.api.exception.ResourceNotFoundException)4 Arrays (java.util.Arrays)4 Collections (java.util.Collections)4