Search in sources :

Example 11 with SimplePermission

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);
}
Also used : LumeerAssertions.assertPermissions(io.lumeer.test.util.LumeerAssertions.assertPermissions) JsonPermissions(io.lumeer.api.dto.JsonPermissions) Permissions(io.lumeer.api.model.Permissions) SimplePermission(io.lumeer.core.model.SimplePermission) Test(org.junit.Test)

Example 12 with SimplePermission

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);
}
Also used : Response(javax.ws.rs.core.Response) Entity(javax.ws.rs.client.Entity) HashSet(java.util.HashSet) Set(java.util.Set) LumeerAssertions.assertPermissions(io.lumeer.test.util.LumeerAssertions.assertPermissions) JsonPermissions(io.lumeer.api.dto.JsonPermissions) Permissions(io.lumeer.api.model.Permissions) JsonPermission(io.lumeer.api.dto.JsonPermission) SimplePermission(io.lumeer.core.model.SimplePermission) Test(org.junit.Test)

Example 13 with SimplePermission

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);
}
Also used : Response(javax.ws.rs.core.Response) Entity(javax.ws.rs.client.Entity) HashSet(java.util.HashSet) Set(java.util.Set) LumeerAssertions.assertPermissions(io.lumeer.test.util.LumeerAssertions.assertPermissions) JsonPermissions(io.lumeer.api.dto.JsonPermissions) MorphiaPermissions(io.lumeer.storage.mongodb.model.embedded.MorphiaPermissions) Permissions(io.lumeer.api.model.Permissions) JsonPermission(io.lumeer.api.dto.JsonPermission) SimplePermission(io.lumeer.core.model.SimplePermission) Test(org.junit.Test)

Example 14 with SimplePermission

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);
}
Also used : Response(javax.ws.rs.core.Response) Entity(javax.ws.rs.client.Entity) HashSet(java.util.HashSet) Set(java.util.Set) LumeerAssertions.assertPermissions(io.lumeer.test.util.LumeerAssertions.assertPermissions) JsonPermissions(io.lumeer.api.dto.JsonPermissions) MorphiaPermissions(io.lumeer.storage.mongodb.model.embedded.MorphiaPermissions) Permissions(io.lumeer.api.model.Permissions) JsonPermission(io.lumeer.api.dto.JsonPermission) SimplePermission(io.lumeer.core.model.SimplePermission) Test(org.junit.Test)

Example 15 with SimplePermission

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);
}
Also used : Response(javax.ws.rs.core.Response) Entity(javax.ws.rs.client.Entity) HashSet(java.util.HashSet) Set(java.util.Set) LumeerAssertions.assertPermissions(io.lumeer.test.util.LumeerAssertions.assertPermissions) JsonPermissions(io.lumeer.api.dto.JsonPermissions) MorphiaPermissions(io.lumeer.storage.mongodb.model.embedded.MorphiaPermissions) Permissions(io.lumeer.api.model.Permissions) JsonPermission(io.lumeer.api.dto.JsonPermission) SimplePermission(io.lumeer.core.model.SimplePermission) Test(org.junit.Test)

Aggregations

SimplePermission (io.lumeer.core.model.SimplePermission)24 Permissions (io.lumeer.api.model.Permissions)16 LumeerAssertions.assertPermissions (io.lumeer.test.util.LumeerAssertions.assertPermissions)16 Test (org.junit.Test)16 JsonPermissions (io.lumeer.api.dto.JsonPermissions)10 JsonPermission (io.lumeer.api.dto.JsonPermission)8 MorphiaPermissions (io.lumeer.storage.mongodb.model.embedded.MorphiaPermissions)8 HashSet (java.util.HashSet)8 Set (java.util.Set)8 Entity (javax.ws.rs.client.Entity)8 Response (javax.ws.rs.core.Response)8 Permission (io.lumeer.api.model.Permission)5 Project (io.lumeer.api.model.Project)3 JsonProject (io.lumeer.api.dto.JsonProject)2 Organization (io.lumeer.api.model.Organization)2 JsonOrganization (io.lumeer.api.dto.JsonOrganization)1 Role (io.lumeer.api.model.Role)1