mirror of
https://github.com/CommunitySolidServer/CommunitySolidServer.git
synced 2024-10-03 14:55:10 +00:00
change: Make credential extractors specialized.
This commit is contained in:
committed by
Joachim Van Herwegen
parent
0407a36490
commit
b0c50b8a7b
20
test/unit/authentication/EmptyCredentialsExtractor.test.ts
Normal file
20
test/unit/authentication/EmptyCredentialsExtractor.test.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import { EmptyCredentialsExtractor } from '../../../src/authentication/EmptyCredentialsExtractor';
|
||||
import type { HttpRequest } from '../../../src/server/HttpRequest';
|
||||
import { NotImplementedHttpError } from '../../../src/util/errors/NotImplementedHttpError';
|
||||
|
||||
describe('An EmptyCredentialsExtractor', (): void => {
|
||||
const extractor = new EmptyCredentialsExtractor();
|
||||
|
||||
it('throws an error if an Authorization header is specified.', async(): Promise<void> => {
|
||||
const headers = { authorization: 'Other http://alice.example/card#me' };
|
||||
const result = extractor.handleSafe({ headers } as HttpRequest);
|
||||
await expect(result).rejects.toThrow(NotImplementedHttpError);
|
||||
await expect(result).rejects.toThrow('Unexpected Authorization scheme.');
|
||||
});
|
||||
|
||||
it('returns the empty credentials.', async(): Promise<void> => {
|
||||
const headers = {};
|
||||
const result = extractor.handleSafe({ headers } as HttpRequest);
|
||||
await expect(result).resolves.toEqual({});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user