Skip to content

Commit

Permalink
Bxc 4435 add permission (#1678)
Browse files Browse the repository at this point in the history
* BXC-4435 add new view settings permission and assign it to a user role

* BXC-4435 update terminology

---------

Co-authored-by: Sharon Luong <[email protected]>
  • Loading branch information
sharonluong and Sharon Luong authored Feb 15, 2024
1 parent dbe2911 commit 5c64298
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public enum Permission {
changePatronAccess,
assignStaffRoles,
editResourceType,
editViewSettings,
runEnhancements,
reindex;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import static edu.unc.lib.boxc.auth.api.Permission.destroy;
import static edu.unc.lib.boxc.auth.api.Permission.editDescription;
import static edu.unc.lib.boxc.auth.api.Permission.editResourceType;
import static edu.unc.lib.boxc.auth.api.Permission.editViewSettings;
import static edu.unc.lib.boxc.auth.api.Permission.ingest;
import static edu.unc.lib.boxc.auth.api.Permission.markForDeletion;
import static edu.unc.lib.boxc.auth.api.Permission.markForDeletionUnit;
Expand Down Expand Up @@ -53,7 +54,8 @@ public enum UserRole {
// Staff roles
canAccess("canAccess", true, canViewOriginals, viewHidden),
canIngest("canIngest", true, canAccess, ingest),
canDescribe("canDescribe", true, canAccess, editDescription, bulkUpdateDescription),
canDescribe("canDescribe", true, canAccess,
editDescription, bulkUpdateDescription, editViewSettings),
canProcess("canProcess", true, canDescribe,
move, orderMembers, markForDeletion, changePatronAccess),
canManage("canManage", true, canProcess,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ public void process(Exchange exchange) throws Exception {
var agent = request.getAgent();
var pid = PIDs.get(request.getObjectPidString());

accessControlService.assertHasAccess("User does not have permission to update view behavior",
pid, agent.getPrincipals(), Permission.ingest);
accessControlService.assertHasAccess("User does not have permission to update view settings",
pid, agent.getPrincipals(), Permission.editViewSettings);

var repositoryObject = repositoryObjectLoader.getRepositoryObject(pid);
var behavior = request.getViewBehavior();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public void testUpdateViewBehaviorNoPermission() throws Exception {

Assertions.assertThrows(AccessRestrictionException.class, () -> {
doThrow(new AccessRestrictionException()).when(accessControlService)
.assertHasAccess(any(), any(PID.class), any(), eq(Permission.ingest));
.assertHasAccess(any(), any(PID.class), any(), eq(Permission.editViewSettings));
processor.process(exchange);
});
}
Expand Down

0 comments on commit 5c64298

Please sign in to comment.