mirror of
https://github.com/CommunitySolidServer/CommunitySolidServer.git
synced 2024-10-03 14:55:10 +00:00
feat: Provide details field when throwing Token ownership error
This commit is contained in:
@@ -91,6 +91,7 @@ export class TokenOwnershipValidator extends OwnershipValidator {
|
||||
'to prove it belongs to you.',
|
||||
'You can remove this triple again after validation.',
|
||||
].join(' ');
|
||||
throw new BadRequestHttpError(errorMessage);
|
||||
const details = { quad: `<${webId}> <${SOLID.oidcIssuerRegistrationToken}> "${token}".` };
|
||||
throw new BadRequestHttpError(errorMessage, { details });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,7 +58,10 @@ describe('A TokenOwnershipValidator', (): void => {
|
||||
it('errors if no token is stored in the storage.', async(): Promise<void> => {
|
||||
// Even if the token is in the WebId, it will error since it's not in the storage
|
||||
mockFetch(tokenString);
|
||||
await expect(validator.handle({ webId })).rejects.toThrow(tokenString);
|
||||
await expect(validator.handle({ webId })).rejects.toThrow(expect.objectContaining({
|
||||
message: expect.stringContaining(tokenString),
|
||||
details: { quad: tokenString },
|
||||
}));
|
||||
expect(fetch).toHaveBeenCalledTimes(0);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user