Skip to content
This repository has been archived by the owner on Apr 13, 2023. It is now read-only.

Commit

Permalink
fix: scopes should not be filtered in search use cases (#79)
Browse files Browse the repository at this point in the history
  • Loading branch information
ssvegaraju authored Mar 11, 2022
1 parent 4e4d796 commit 67af26d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
14 changes: 14 additions & 0 deletions src/smartScopeHelper.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,20 @@ describe('filterOutUnusableScope', () => {
),
).toEqual(['system/*.write']);
});

test('do not filter patient scope out in type-search use case', () => {
const clonedScopeRule = emptyScopeRule();
clonedScopeRule.system.read = ['search-type'];
expect(
filterOutUnusableScope(
['system/DocumentReference.read', 'system/Patient.read'],
clonedScopeRule,
'search-type',
false,
'DocumentReference',
),
).toEqual(['system/DocumentReference.read', 'system/Patient.read']);
});
});

describe('getValidOperationsForScopeTypeAndAccessType', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/smartScopeHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ function getValidOperationsForScope(
let validOperations: (TypeOperation | SystemOperation)[] = [];
const { scopeType, resourceType, accessType } = smartScope;
if (reqResourceType) {
if (resourceType === '*' || resourceType === reqResourceType) {
if (resourceType === '*' || resourceType === reqResourceType || reqOperation === 'search-type') {
validOperations = getValidOperationsForScopeTypeAndAccessType(scopeType, accessType, scopeRule);
}
}
Expand Down

0 comments on commit 67af26d

Please sign in to comment.