Skip to content

Commit

Permalink
Fix JWT tests to support Node 20
Browse files Browse the repository at this point in the history
  • Loading branch information
Loïc Poullain committed Sep 2, 2023
1 parent 9f73a53 commit 17773c7
Showing 1 changed file with 22 additions and 8 deletions.
30 changes: 22 additions & 8 deletions packages/jwt/src/http/jwt.hook.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -299,14 +299,28 @@ export function testSuite(JWT: typeof JWTOptional|typeof JWTRequired, required:
if (!isHttpResponseUnauthorized(response)) {
throw new Error('response should be instance of HttpResponseUnauthorized');
}
deepStrictEqual(response.body, {
code: 'invalid_token',
description: 'Unexpected token R in JSON at position 27'
});
strictEqual(
response.getHeader('WWW-Authenticate'),
'error="invalid_token", error_description="Unexpected token R in JSON at position 27"'
);
try {
deepStrictEqual(response.body, {
code: 'invalid_token',
description: 'Unexpected token R in JSON at position 27'
});
} catch {
deepStrictEqual(response.body, {
code: 'invalid_token',
description: `Unexpected token 'R', ...\"0\",\"name\":RJohn Doe\"\"... is not valid JSON`
});
}
try {
strictEqual(
response.getHeader('WWW-Authenticate'),
'error="invalid_token", error_description="Unexpected token R in JSON at position 27"'
);
} catch {
strictEqual(
response.getHeader('WWW-Authenticate'),
`error="invalid_token", error_description="Unexpected token 'R', ...\"0\",\"name\":RJohn Doe\"\"... is not valid JSON"`
);
}
});

it('should return an HttpResponseUnauthorized object if options.secretOrPublicKey throws an'
Expand Down

0 comments on commit 17773c7

Please sign in to comment.