use of org.molgenis.data.security.EntityIdentity in project molgenis by molgenis.
the class RowLevelSecurityRepositoryDecoratorTest method testAdd.
@WithMockUser(username = USERNAME)
@Test
public void testAdd() {
Entity entity = getEntityMock();
MutableAcl acl = mock(MutableAcl.class);
when(mutableAclService.createAcl(new EntityIdentity(entity))).thenReturn(acl);
rowLevelSecurityRepositoryDecorator.add(entity);
verify(acl).insertAce(0, new CumulativePermission().set(WRITE).set(READ).set(COUNT), new PrincipalSid(USERNAME), true);
verify(delegateRepository).add(entity);
}
use of org.molgenis.data.security.EntityIdentity in project molgenis by molgenis.
the class RowLevelSecurityRepositoryDecoratorTest method testDeleteStreamPermissionDenied.
@Test
public void testDeleteStreamPermissionDenied() {
Entity entity = getEntityMock();
rowLevelSecurityRepositoryDecorator.delete(Stream.of(entity));
@SuppressWarnings("unchecked") ArgumentCaptor<Stream<Entity>> entityStreamCaptor = ArgumentCaptor.forClass(Stream.class);
verify(delegateRepository).delete(entityStreamCaptor.capture());
assertEquals(entityStreamCaptor.getValue().collect(toList()), emptyList());
verify(mutableAclService, times(0)).deleteAcl(new EntityIdentity(entity), true);
}
use of org.molgenis.data.security.EntityIdentity in project molgenis by molgenis.
the class RowLevelSecurityRepositoryDecoratorTest method testUpdate.
@Test
public void testUpdate() {
Entity entity = getEntityMock();
when(userPermissionEvaluator.hasPermission(new EntityIdentity(entity), WRITE)).thenReturn(true);
rowLevelSecurityRepositoryDecorator.update(entity);
verify(delegateRepository).update(entity);
}
use of org.molgenis.data.security.EntityIdentity in project molgenis by molgenis.
the class RowLevelSecurityRepositoryDecoratorTest method testFindOneById.
@Test
public void testFindOneById() {
String entityTypeId = "entityTypeId";
EntityType entityType = when(mock(EntityType.class).getId()).thenReturn(entityTypeId).getMock();
when(delegateRepository.getEntityType()).thenReturn(entityType);
Object entityId = "entityId";
when(userPermissionEvaluator.hasPermission(new EntityIdentity(entityTypeId, entityId), READ)).thenReturn(true);
Entity entity = mock(Entity.class);
when(delegateRepository.findOneById(entityId)).thenReturn(entity);
assertEquals(rowLevelSecurityRepositoryDecorator.findOneById(entityId), entity);
}
use of org.molgenis.data.security.EntityIdentity in project molgenis by molgenis.
the class RowLevelSecurityRepositoryDecoratorTest method testDeleteAllStreamPermissionDenied.
@Test
public void testDeleteAllStreamPermissionDenied() {
String entityTypeId = "entityTypeId";
EntityType entityType = when(mock(EntityType.class).getId()).thenReturn(entityTypeId).getMock();
when(delegateRepository.getEntityType()).thenReturn(entityType);
Object entityId = "entityId";
rowLevelSecurityRepositoryDecorator.deleteAll(Stream.of(entityId));
@SuppressWarnings("unchecked") ArgumentCaptor<Stream<Object>> entityStreamCaptor = ArgumentCaptor.forClass(Stream.class);
verify(delegateRepository).deleteAll(entityStreamCaptor.capture());
assertEquals(entityStreamCaptor.getValue().collect(toList()), emptyList());
verify(mutableAclService, times(0)).deleteAcl(new EntityIdentity(entityTypeId, entityId), true);
}
Aggregations