feat: Let Authorizers output an Authorization

This commit is contained in:
Joachim Van Herwegen
2021-02-16 15:59:41 +01:00
parent 8ccc68d29c
commit f2f265c586
12 changed files with 212 additions and 28 deletions

View File

@@ -1,13 +1,23 @@
import { AllowEverythingAuthorizer } from '../../../src/authorization/AllowEverythingAuthorizer';
import type { PermissionSet } from '../../../src/ldp/permissions/PermissionSet';
describe('An AllowEverythingAuthorizer', (): void => {
const authorizer = new AllowEverythingAuthorizer();
const allowEverything: PermissionSet = {
read: true,
write: true,
append: true,
control: true,
};
it('can handle everything.', async(): Promise<void> => {
await expect(authorizer.canHandle({} as any)).resolves.toBeUndefined();
});
it('always returns undefined.', async(): Promise<void> => {
await expect(authorizer.handle()).resolves.toBeUndefined();
it('always returns an empty Authorization.', async(): Promise<void> => {
await expect(authorizer.handle()).resolves.toEqual({
user: allowEverything,
everyone: allowEverything,
});
});
});