fix: Accept lowercase Authorization tokens.

This commit is contained in:
Ruben Verborgh
2021-12-03 11:55:43 +01:00
parent 5a01f09f81
commit 9c52011add
6 changed files with 42 additions and 5 deletions

View File

@@ -20,9 +20,15 @@ describe('An UnsecureWebIdExtractor', (): void => {
await expect(result).rejects.toThrow('No WebID Authorization header specified.');
});
it('returns the authorization header as WebID if there is one.', async(): Promise<void> => {
it('returns the authorization header as WebID if specified.', async(): Promise<void> => {
const headers = { authorization: 'WebID http://alice.example/card#me' };
const result = extractor.handleSafe({ headers } as HttpRequest);
await expect(result).resolves.toEqual({ [CredentialGroup.agent]: { webId: 'http://alice.example/card#me' }});
});
it('returns the authorization header as WebID if specified with a lowercase token.', async(): Promise<void> => {
const headers = { authorization: 'webid http://alice.example/card#me' };
const result = extractor.handleSafe({ headers } as HttpRequest);
await expect(result).resolves.toEqual({ [CredentialGroup.agent]: { webId: 'http://alice.example/card#me' }});
});
});