Skip to content

Commit

Permalink
refactor: added codes and reasons to as many errors as possible
Browse files Browse the repository at this point in the history
  • Loading branch information
panva committed Oct 7, 2024
1 parent a1cb7f8 commit bce81b4
Show file tree
Hide file tree
Showing 21 changed files with 818 additions and 543 deletions.
2 changes: 1 addition & 1 deletion conformance/fapi/ensure-jarm-with-expired-exp-fails.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ for (const module of modules('ensure-jarm-with-expired-exp-fails')) {
test.serial(
rejects(flow()),
module,
'unexpected JWT "exp" (expiration time) claim value, timestamp is <= now()',
'unexpected JWT "exp" (expiration time) claim value, expiration is past current timestamp',
)
}
2 changes: 1 addition & 1 deletion conformance/fapi/invalid-expired-exp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ for (const module of modules('invalid-expired-exp')) {
test.serial(
rejects(flow()),
module,
'unexpected JWT "exp" (expiration time) claim value, timestamp is <= now()',
'unexpected JWT "exp" (expiration time) claim value, expiration is past current timestamp',
'OperationProcessingError',
)
}
6 changes: 5 additions & 1 deletion conformance/oidc/discovery-issuer-mismatch.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import { test, rejects, flow, modules } from '../runner.js'

for (const module of modules('discovery-issuer-mismatch')) {
test.serial(rejects(flow()), module, '"response" body "issuer" does not match "expectedIssuer"')
test.serial(
rejects(flow()),
module,
'"response" body "issuer" property does not match the expected value',
)
}
2 changes: 1 addition & 1 deletion conformance/oidc/userinfo-invalid-sub.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { test, rejects, flow, modules } from '../runner.js'

for (const module of modules('userinfo-invalid-sub')) {
test.serial(rejects(flow()), module, 'unexpected "response" body "sub" value')
test.serial(rejects(flow()), module, 'unexpected "response" body "sub" property value')
}
4 changes: 2 additions & 2 deletions conformance/runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -331,8 +331,8 @@ export const flow = (options?: MacroOptions) => {
try {
result = await oauth.processPushedAuthorizationResponse(as, client, par)
} catch (err) {
t.log('error', inspect(err, { depth: Infinity }))
if (DPoP && err instanceof oauth.ResponseBodyError && err.error === 'use_dpop_nonce') {
t.log('error', inspect(err, { depth: Infinity }))
t.log('retrying with a newly obtained dpop nonce')
par = await request()
result = await oauth.processPushedAuthorizationResponse(as, client, par)
Expand Down Expand Up @@ -403,8 +403,8 @@ export const flow = (options?: MacroOptions) => {
result = await oauth.processAuthorizationCodeOAuth2Response(as, client, response)
}
} catch (err) {
t.log('error', inspect(err, { depth: Infinity }))
if (DPoP && err instanceof oauth.ResponseBodyError && err.error === 'use_dpop_nonce') {
t.log('error', inspect(err, { depth: Infinity }))
t.log('retrying with a newly obtained dpop nonce')
response = await request()
if (scope.includes('openid')) {
Expand Down
Loading

0 comments on commit bce81b4

Please sign in to comment.