feat: add simple permissions related handlers

This commit is contained in:
Joachim Van Herwegen
2020-06-23 10:13:23 +02:00
parent e0343fca54
commit d983fca8f5
7 changed files with 133 additions and 1 deletions

View File

@@ -0,0 +1,17 @@
import { AuthorizerArgs } from '../../../src/authorization/Authorizer';
import { SimpleAuthorizer } from '../../../src/authorization/SimpleAuthorizer';
import { UnsupportedHttpError } from '../../../src/util/errors/UnsupportedHttpError';
describe('A SimpleAuthorizer', (): void => {
const authorizer = new SimpleAuthorizer();
it('requires input to have an identifier and permissions.', async(): Promise<void> => {
await expect(authorizer.canHandle({ identifier: {}, permissions: {}} as AuthorizerArgs)).resolves.toBeUndefined();
await expect(authorizer.canHandle({ identifier: {}} as AuthorizerArgs)).rejects.toThrow(UnsupportedHttpError);
await expect(authorizer.canHandle({ permissions: {}} as AuthorizerArgs)).rejects.toThrow(UnsupportedHttpError);
});
it('always returns undefined.', async(): Promise<void> => {
await expect(authorizer.handle()).resolves.toBeUndefined();
});
});