Skip to content

Commit

Permalink
feat: Provide details field when throwing Token ownership error
Browse files Browse the repository at this point in the history
  • Loading branch information
joachimvh committed Sep 8, 2021
1 parent cc1c3d9 commit e31cd38
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/identity/ownership/TokenOwnershipValidator.ts
Expand Up @@ -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 });
}
}
5 changes: 4 additions & 1 deletion test/unit/identity/ownership/TokenOwnershipValidator.test.ts
Expand Up @@ -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);
});

Expand Down

0 comments on commit e31cd38

Please sign in to comment.