feat: Add permissions extractor for acl resources

This commit is contained in:
Joachim Van Herwegen
2021-01-29 16:48:09 +01:00
parent 758f5ed083
commit 8339413ab4
8 changed files with 94 additions and 26 deletions

View File

@@ -120,18 +120,6 @@ describe('A WebAclAuthorizer', (): void => {
await expect(authorizer.handle({ identifier, permissions, credentials })).rejects.toThrow(ForbiddenHttpError);
});
it('allows access to the acl file if control is allowed.', async(): Promise<void> => {
credentials.webId = 'http://test.com/user';
identifier.path = 'http://test.com/foo';
store.getRepresentation = async(): Promise<Representation> => ({ data: streamifyArray([
quad(nn('auth'), nn(`${acl}agent`), nn(credentials.webId!)),
quad(nn('auth'), nn(`${acl}accessTo`), nn(identifier.path)),
quad(nn('auth'), nn(`${acl}mode`), nn(`${acl}Control`)),
]) } as Representation);
const aclIdentifier = aclStrategy.getAuxiliaryIdentifier(identifier);
await expect(authorizer.handle({ identifier: aclIdentifier, permissions, credentials })).resolves.toBeUndefined();
});
it('errors if an agent tries to edit the acl file without control permissions.', async(): Promise<void> => {
credentials.webId = 'http://test.com/user';
identifier.path = 'http://test.com/foo';