-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix: Collection's admin cannot edit its template item. #8851
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@buithaihai : Thanks for this PR! First off, I can verify that this code fixes the bug entirely. Everything works.
However, this PR is missing automated tests. Could you add some new tests to ItemTemplateRestControllerIT
which prove that a Collection Admin can create, edit & delete a template item?
It shouldn't be too complex to add the new tests... you just need to create a Collection Admin user in createStructure()
similar to this:
collectionAdmin = EPersonBuilder.createEPerson(context)
.withNameInMetadata("Jane", "Brown")
.withEmail("collectionAdmin@my.edu")
.withPassword(password)
.build();
childCollection = CollectionBuilder.createCollection(context, parentCommunity)
.withName("Collection 1")
.withAdminGroup(collectionAdmin)
.build();
Then you should be able to used that person in tests as the authenticated person & verify they have proper permissions.
Beyond that, great work! If you need any help on the tests let us know.
56280c6
to
aa197fd
Compare
@tdonohue I have made the requested changes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 Thank you @buithaihai ! The new tests look good, and as I mentioned previously I was able to verify that this fixes the bug.
References
Fix #8832
Description
This fixes the error at step 6 of #8832.
In addition, this PR also applies to Template Item removal action.
Instructions for Reviewers
List of changes in this PR:
RestObjectPermissionEvaluatorPlugin
forTemplateItem
to perform extra evaluations when editing or deleting a template item.RestObjectPermissionEvaluatorPlugin
would be ideal, but none suffices. The best candidate I found isWorkspaceItemRestPermissionEvaluatorPlugin
but it is too specific to WorkspaceItem to rewrite easily.'ITEM'
to'ITEMTEMPLATE'
in@PreAuthorize("hasPermission(...)")
of methodspatch()
anddeleteTemplateItem()
to take advantage of existingTemplateItemRest
class, in order to distinguish it further from the genericItem
term.Checklist
pom.xml
), I've made sure their licenses align with the DSpace BSD License based on the Licensing of Contributions documentation.