From 7dc2f277ac862df8bf530a32daaf20f2e6b80299 Mon Sep 17 00:00:00 2001 From: Karan Malhotra Date: Mon, 23 Apr 2018 16:26:56 +0530 Subject: [PATCH 1/2] Mark base class (AbstractAclObjectIdentity) as @DirtyCheck Required (since GORM 6.1) for Dirty checking to correctly work --- .../plugin/springsecurity/acl/AbstractAclObjectIdentity.groovy | 3 +++ 1 file changed, 3 insertions(+) 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 From 478c7c1841447338687c73d05041314816bf26e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20Hron?= Date: Thu, 8 Aug 2019 16:38:27 +0200 Subject: [PATCH 2/2] Added test for AclUtilService.changeOwner which is failing without kmalhotra:patch-1 --- .../acl/AclUtilServiceSpec.groovy | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) 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 + } }