CCM NG: Changes for the PermissionManager to pass tests.

git-svn-id: https://svn.libreccm.org/ccm/ccm_ng@4535 8810af33-2d31-482b-a856-94f89814c4df

Former-commit-id: 39b74d511a
pull/2/head
jensp 2017-01-24 16:32:57 +00:00
parent c0315684c7
commit 60a545456a
5 changed files with 125 additions and 120 deletions

View File

@ -241,9 +241,6 @@ public class ContentItem extends CcmObject implements Serializable,
@Column(name = "ANCESTORS", length = 1024) @Column(name = "ANCESTORS", length = 1024)
private String ancestors; private String ancestors;
@RecursivePermissions(privileges = {AssetPrivileges.EDIT,
AssetPrivileges.DELETE,
AssetPrivileges.VIEW})
@OneToMany(mappedBy = "item") @OneToMany(mappedBy = "item")
private List<AttachmentList> attachments; private List<AttachmentList> attachments;

View File

@ -142,7 +142,7 @@ public class PermissionManager {
return; return;
} }
if (field.getType().equals(Collection.class)) { if (Collection.class.isAssignableFrom(field.getType())) {
final Collection<?> collection = (Collection<?>) value; final Collection<?> collection = (Collection<?>) value;
collection.stream() collection.stream()
.filter(obj -> obj instanceof CcmObject) .filter(obj -> obj instanceof CcmObject)
@ -154,9 +154,9 @@ public class PermissionManager {
.filter(relation -> relation.getRelatedObject() != null) .filter(relation -> relation.getRelatedObject() != null)
.map(relation -> relation.getRelatedObject()) .map(relation -> relation.getRelatedObject())
.forEach(obj -> grantPrivilege(privilege, grantee, obj)); .forEach(obj -> grantPrivilege(privilege, grantee, obj));
} else if (field.getType().equals(CcmObject.class)) { } else if (CcmObject.class.isAssignableFrom(field.getType())) {
grantPrivilege(privilege, grantee, (CcmObject) value); grantPrivilege(privilege, grantee, (CcmObject) value);
} else if (field.getType().equals(Relation.class)) { } else if (Relation.class.isAssignableFrom(field.getType())) {
final Relation relation = (Relation) value; final Relation relation = (Relation) value;
if (relation.getRelatedObject() != null) { if (relation.getRelatedObject() != null) {
grantPrivilege(privilege, grantee, relation.getRelatedObject()); grantPrivilege(privilege, grantee, relation.getRelatedObject());

View File

@ -106,8 +106,8 @@ public class PermissionManagerTest {
public static WebArchive createDeployment() { public static WebArchive createDeployment() {
return ShrinkWrap return ShrinkWrap
.create(WebArchive.class, .create(WebArchive.class,
"LibreCCM-org.libreccm.security.PermissionManagerTest.war") "LibreCCM-org.libreccm.security.PermissionManagerTest.war").
.addPackage(org.libreccm.categorization.Categorization.class addPackage(org.libreccm.categorization.Categorization.class
.getPackage()) .getPackage())
.addPackage(org.libreccm.configuration.Configuration.class .addPackage(org.libreccm.configuration.Configuration.class
.getPackage()) .getPackage())
@ -116,16 +116,16 @@ public class PermissionManagerTest {
.getPackage()) .getPackage())
.addPackage(org.libreccm.jpa.utils.MimeTypeConverter.class .addPackage(org.libreccm.jpa.utils.MimeTypeConverter.class
.getPackage()) .getPackage())
.addPackage(org.libreccm.l10n.LocalizedString.class.getPackage()) .addPackage(org.libreccm.l10n.LocalizedString.class.getPackage()).
.addPackage(org.libreccm.security.User.class.getPackage()) addPackage(org.libreccm.security.User.class.getPackage())
.addPackage(org.libreccm.tests.categories.IntegrationTest.class .addPackage(org.libreccm.tests.categories.IntegrationTest.class
.getPackage()) .getPackage())
.addPackage(org.libreccm.testutils.EqualsVerifier.class .addPackage(org.libreccm.testutils.EqualsVerifier.class
.getPackage()) .getPackage())
.addPackage(org.libreccm.web.CcmApplication.class.getPackage()) .addPackage(org.libreccm.web.CcmApplication.class.getPackage())
.addPackage(org.libreccm.workflow.Workflow.class.getPackage()) .addPackage(org.libreccm.workflow.Workflow.class.getPackage())
.addPackage(com.arsdigita.kernel.KernelConfig.class.getPackage()) .addPackage(com.arsdigita.kernel.KernelConfig.class.getPackage()).
.addPackage(com.arsdigita.kernel.security.SecurityConfig.class addPackage(com.arsdigita.kernel.security.SecurityConfig.class
.getPackage()) .getPackage())
.addPackage(com.arsdigita.util.UncheckedWrapperException.class .addPackage(com.arsdigita.util.UncheckedWrapperException.class
.getPackage()) .getPackage())
@ -226,7 +226,8 @@ public class PermissionManagerTest {
@ShouldMatchDataSet( @ShouldMatchDataSet(
value = "datasets/org/libreccm/security/PermissionManagerTest/" value = "datasets/org/libreccm/security/PermissionManagerTest/"
+ "after-grant-recursivly.yml", + "after-grant-recursivly.yml",
excludeColumns = {"permission_id"}) excludeColumns = {"permission_id"},
orderBy = {"permissions.permission_id desc"})
@InSequence(211) @InSequence(211)
public void grantPermissionRecursively() { public void grantPermissionRecursively() {
final Role role1 = roleRepository.findByName("role1"); final Role role1 = roleRepository.findByName("role1");
@ -565,7 +566,8 @@ public class PermissionManagerTest {
try { try {
shiro.getSystemUser().execute( shiro.getSystemUser().execute(
() -> permissionManager.revokePrivilege(null, role1, object1)); () -> permissionManager.
revokePrivilege(null, role1, object1));
} catch (ExecutionException ex) { } catch (ExecutionException ex) {
throw ex.getCause(); throw ex.getCause();
} }

View File

@ -43,6 +43,9 @@ ccm_core.categorizations:
- categorization_id: -40001 - categorization_id: -40001
category_id: -20003 category_id: -20003
object_id: -20004 object_id: -20004
category_index: false
category_order: 0
object_order: 0
ccm_core.permissions: ccm_core.permissions:
- permission_id: -30001 - permission_id: -30001
granted_privilege: privilege1 granted_privilege: privilege1

View File

@ -43,6 +43,9 @@ ccm_core.categorizations:
- categorization_id: -40001 - categorization_id: -40001
category_id: -20003 category_id: -20003
object_id: -20004 object_id: -20004
category_index: false
category_order: 0
object_order: 0
ccm_core.permissions: ccm_core.permissions:
- permission_id: -30001 - permission_id: -30001
granted_privilege: privilege1 granted_privilege: privilege1