Skip to content
This repository was archived by the owner on Mar 10, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
*/
package grails.plugin.springsecurity.acl

import grails.gorm.dirty.checking.DirtyCheck

import groovy.transform.EqualsAndHashCode
import groovy.transform.ToString

Expand All @@ -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
Expand Down