Skip to content

Commit

Permalink
Merge pull request hms-dbmi-cellenics#489 from biomage-org/fix-explor…
Browse files Browse the repository at this point in the history
…ers-work-auth

Add workRequest permissions for explorers
  • Loading branch information
cosa65 authored Oct 5, 2023
2 parents 6b9fb67 + 7240975 commit aebec9e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/api.v2/helpers/roles.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const allowedResources = {
'/experiments/(?<experimentId>.*)/cellSets',
'/experiments/(?<experimentId>.*)/clone',
'/experiments/(?<experimentId>.*)/subset',
'/workRequest/(?<experimentId>.*)/.*',
],
[VIEWER]: [
'/experiments/(?<experimentId>.*)/clone',
Expand Down
10 changes: 10 additions & 0 deletions tests/api.v2/helpers/roles.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,16 @@ describe('tests for the roles logic', () => {
});
});

test(' isRoleAuthorized authorizes explorer to perform work requests', async () => {
[
`/workRequest/${fake.EXPERIMENT_ID}/010c3cd044ca5b61dffee5204a9ee893`,
`/workRequest/${fake.EXPERIMENT_ID}/02456e45d0bb165ed6961795ac438cd7`,
].forEach((resource) => {
const isAuthorized = roles.isRoleAuthorized(roles.EXPLORER, resource, 'POST');
expect(isAuthorized).toEqual(true);
});
});

test(' isRoleAuthorized authorizes admin & owner roles to everything', async () => {
[roles.OWNER, roles.ADMIN].forEach((role) => {
['*', 'socket', '/experiments'].forEach((resource) => {
Expand Down

0 comments on commit aebec9e

Please sign in to comment.