use of org.molgenis.data.security.EntityTypeIdentity in project molgenis by molgenis.
the class MolgenisPermissionControllerTest method hasWritePermissionFalse.
@Test
public void hasWritePermissionFalse() {
String entityTypeId = "entity";
when(permissionService.hasPermission(new EntityTypeIdentity(entityTypeId), EntityTypePermission.WRITE)).thenReturn(false);
assertFalse(molgenisPermissionController.hasWritePermission(entityTypeId));
}
use of org.molgenis.data.security.EntityTypeIdentity in project molgenis by molgenis.
the class EntityTypeRepositorySecurityDecoratorTest method findOneByIdFetchUserPermissionAllowed.
@WithMockUser(username = USERNAME)
@Test
public void findOneByIdFetchUserPermissionAllowed() {
String entityType0Name = "entity0";
EntityType entityType0 = mock(EntityType.class);
Fetch fetch = mock(Fetch.class);
when(delegateRepository.findOneById(entityType0Name, fetch)).thenReturn(entityType0);
when(permissionService.hasPermission(new EntityTypeIdentity(entityType0Name), EntityTypePermission.COUNT)).thenReturn(true);
assertEquals(repo.findOneById(entityType0Name, fetch), entityType0);
}
use of org.molgenis.data.security.EntityTypeIdentity in project molgenis by molgenis.
the class EntityTypeRepositorySecurityDecoratorTest method update.
@WithMockUser(username = USERNAME)
@Test
public void update() {
String entityTypeId = "entityTypeId";
when(permissionService.hasPermission(new EntityTypeIdentity(entityTypeId), EntityTypePermission.WRITEMETA)).thenReturn(true);
EntityType entityType = mock(EntityType.class);
when(entityType.getId()).thenReturn(entityTypeId).getMock();
repo.update(entityType);
verify(delegateRepository).update(entityType);
}
use of org.molgenis.data.security.EntityTypeIdentity in project molgenis by molgenis.
the class EntityTypeRepositorySecurityDecoratorTest method deleteNotAllowed.
@WithMockUser(username = USERNAME)
@Test(expectedExceptions = MolgenisDataAccessException.class, expectedExceptionsMessageRegExp = "No \\[WRITEMETA\\] permission on entity type \\[Entity type\\] with id \\[entityTypeId\\]")
public void deleteNotAllowed() {
String entityTypeId = "entityTypeId";
when(permissionService.hasPermission(new EntityTypeIdentity(entityTypeId), EntityTypePermission.WRITEMETA)).thenReturn(false);
EntityType entityType = mock(EntityType.class);
when(entityType.getId()).thenReturn("entityTypeId").getMock();
when(entityType.getIdValue()).thenReturn("entityTypeId");
when(entityType.getLabel()).thenReturn("Entity type").getMock();
when(entityType.getEntityType()).thenReturn(entityType);
repo.delete(entityType);
}
use of org.molgenis.data.security.EntityTypeIdentity in project molgenis by molgenis.
the class EntityTypeRepositorySecurityDecoratorTest method updateNotAllowed.
@WithMockUser(username = USERNAME)
@Test(expectedExceptions = MolgenisDataAccessException.class, expectedExceptionsMessageRegExp = "No \\[WRITEMETA\\] permission on entity type \\[Entity type\\] with id \\[entityTypeId\\]")
public void updateNotAllowed() {
String entityTypeId = "entityTypeId";
when(permissionService.hasPermission(new EntityTypeIdentity(entityTypeId), EntityTypePermission.WRITEMETA)).thenReturn(false);
EntityType entityType = mock(EntityType.class);
when(entityType.getId()).thenReturn(entityTypeId).getMock();
when(entityType.getIdValue()).thenReturn(entityTypeId).getMock();
when(entityType.getLabel()).thenReturn("Entity type").getMock();
when(entityType.getEntityType()).thenReturn(entityType);
repo.update(entityType);
}
Aggregations