use of org.molgenis.data.security.EntityTypeIdentity in project molgenis by molgenis.
the class StaticContentServiceImplTest method checkPermissionsNoException.
@Test
public void checkPermissionsNoException() {
doReturn(true).when(permissionService).hasPermission(new EntityTypeIdentity(STATIC_CONTENT), EntityTypePermission.WRITE);
staticContentService.checkPermissions("home");
}
use of org.molgenis.data.security.EntityTypeIdentity in project molgenis by molgenis.
the class StaticContentServiceImplTest method isCurrentUserCanEditTrue.
@Test
public void isCurrentUserCanEditTrue() {
doReturn(true).when(permissionService).hasPermission(new EntityTypeIdentity(STATIC_CONTENT), EntityTypePermission.WRITE);
assertTrue(staticContentService.isCurrentUserCanEdit("home"));
}
use of org.molgenis.data.security.EntityTypeIdentity in project molgenis by molgenis.
the class StaticContentServiceImplTest method submitContentNew.
@Test
public void submitContentNew() {
when(dataService.findOneById(STATIC_CONTENT, "home", StaticContent.class)).thenReturn(null);
when(staticContentFactory.create("home")).thenReturn(staticContent);
doReturn(true).when(permissionService).hasPermission(new EntityTypeIdentity(STATIC_CONTENT), EntityTypePermission.WRITE);
assertTrue(this.staticContentService.submitContent("home", "<p>New Content!</p>"));
verify(staticContent).setContent("<p>New Content!</p>");
verify(dataService).add(STATIC_CONTENT, staticContent);
}
use of org.molgenis.data.security.EntityTypeIdentity in project molgenis by molgenis.
the class StaticContentServiceImplTest method isCurrentUserCanEditNoEntityTypePermissionFalse.
@Test
public void isCurrentUserCanEditNoEntityTypePermissionFalse() {
doReturn(false).when(permissionService).hasPermission(new EntityTypeIdentity(STATIC_CONTENT), EntityTypePermission.WRITE);
assertFalse(staticContentService.isCurrentUserCanEdit("home"));
}
use of org.molgenis.data.security.EntityTypeIdentity in project molgenis by molgenis.
the class OntologyImportServiceIT method populateUserPermissions.
private void populateUserPermissions() {
Sid sid = new PrincipalSid(SecurityUtils.getCurrentUsername());
Map<String, EntityTypePermission> entityTypePermissionMap = new HashMap<>();
entityTypePermissionMap.put("sys_ont_OntologyTermDynamicAnnotation", WRITE);
entityTypePermissionMap.put("sys_ont_OntologyTermNodePath", WRITE);
entityTypePermissionMap.put("sys_ont_OntologyTermSynonym", WRITE);
entityTypePermissionMap.put("sys_ont_Ontology", WRITE);
entityTypePermissionMap.put("sys_ont_OntologyTerm", WRITE);
entityTypePermissionMap.put("sys_dec_DecoratorConfiguration", READ);
runAsSystem(() -> entityTypePermissionMap.forEach((entityTypeId, permission) -> {
MutableAcl acl = (MutableAcl) mutableAclService.readAclById(new EntityTypeIdentity(entityTypeId));
acl.insertAce(acl.getEntries().size(), getCumulativePermission(permission), sid, true);
mutableAclService.updateAcl(acl);
}));
}
Aggregations