diff --git a/integration-test-app/src/integration-test/groovy/grails/plugin/springsecurity/acl/AclUtilServiceSpec.groovy b/integration-test-app/src/integration-test/groovy/grails/plugin/springsecurity/acl/AclUtilServiceSpec.groovy index 2fb80e2..28d61ee 100644 --- a/integration-test-app/src/integration-test/groovy/grails/plugin/springsecurity/acl/AclUtilServiceSpec.groovy +++ b/integration-test-app/src/integration-test/groovy/grails/plugin/springsecurity/acl/AclUtilServiceSpec.groovy @@ -175,4 +175,36 @@ class AclUtilServiceSpec extends AbstractAclSpec { ProxyUtils.isProxy report.getClass() aclUtilService.hasPermission(authenticateAsUser(false), report, WRITE) } + + void 'change owner'() { + given: + buildReports() + AclSid sid = new AclSid(sid: 'ben', principal: true).save(failOnError: true) + def report = Report.get(report1Id) + AclClass aclClass = new AclClass(className: Report.name).save(failOnError: true) + AclObjectIdentity aclObjectIdentity = new AclObjectIdentity( + aclClass: aclClass, + objectId: report1Id, + owner: sid, + entriesInheriting: true).save(failOnError: true) + + new AclEntry( + aclObjectIdentity: aclObjectIdentity, + sid: sid, + mask: 1, + granting: true).save(failOnError: true) + flushAndClear() + + expect: 'persistent data to be same as Acl' + aclUtilService.readAcl(report).owner.principal == AclObjectIdentity.findByObjectId(report1Id).owner.sid + + when: + authenticateAsAdmin() + aclUtilService.changeOwner(report, 'admin') + flushAndClear() + + then: "compare Acl with persistent data" + def aoi1 = AclObjectIdentity.findByObjectId(report1Id) + aclUtilService.readAcl(report).owner.principal == aoi1.owner.sid + } } diff --git a/plugin/src/main/groovy/grails/plugin/springsecurity/acl/AbstractAclObjectIdentity.groovy b/plugin/src/main/groovy/grails/plugin/springsecurity/acl/AbstractAclObjectIdentity.groovy index fe9edb6..c8d0cad 100644 --- a/plugin/src/main/groovy/grails/plugin/springsecurity/acl/AbstractAclObjectIdentity.groovy +++ b/plugin/src/main/groovy/grails/plugin/springsecurity/acl/AbstractAclObjectIdentity.groovy @@ -14,6 +14,8 @@ */ package grails.plugin.springsecurity.acl +import grails.gorm.dirty.checking.DirtyCheck + import groovy.transform.EqualsAndHashCode import groovy.transform.ToString @@ -25,6 +27,7 @@ import groovy.transform.ToString */ @EqualsAndHashCode(includes=['aclClass', 'parent', 'owner', 'entriesInheriting']) @ToString(includeNames=true) +@DirtyCheck abstract class AbstractAclObjectIdentity implements Serializable { AclClass aclClass