Skip to content

test(client): cover unprotected client, resource and JOSE checks - #810

Merged
osanderson merged 1 commit into
mainfrom
test/client-resource-crypto-coverage-gaps
Nov 8, 2026
Merged

osanderson merged 1 commit into
mainfrom
test/client-resource-crypto-coverage-gaps

Conversation

@osanderson

Copy link
Copy Markdown
Collaborator

Test-only. Each test below guards a verification check that the existing suite didn't protect: removing, inverting or forcing the check left go test ./... green. Every new test fails against that mutant and passes on the unmodified code.

internal/token

  • TestIDTokenValidateRejectsOnlyTrustedAudiences: an ID token whose aud lists only TrustedAudiences and never the client is ErrAudienceMismatch, with and without azp (validate.go !sawExpectedAudience)

client

  • TestHandleAuthorizationResponseRejectsUnverifiableJARM: a JARM response with the wrong signing key, wrong iss, wrong aud, an exp in the past, or an exp beyond MaxJARMResponseLifetime is refused as invalid_response, wrapping the matching sentinel error
  • TestPollBackchannelAuthenticationRejectsBearerUnderDPoP: a CIBA poll response with token_type: Bearer is refused for a DPoP client
  • TestNewProductionRequires{Client,Decryption}KeyCustody: production refuses declared but non-Durable custody for Keys and Decryption
  • TestNewNamesEachEncryptionAndMessageSigningRefusal: each of these is refused with its own error: invalid ID token / UserInfo key-management and content-encryption algorithms, a missing JARM algorithm, a zero or over-60-minute request object lifetime, and a zero MaxJARMResponseLifetime. Exactly 60 minutes is accepted.

resource

  • TestVerifyResolvesPairwiseSubjects: a new case where the pairwise lookup returns ("", nil), which gives a 500
  • TestVerifyChecksTheCodeGrantRevocation: each case now also runs with a RevocationBatchChecker, so a token carrying only code_grant_id must still have its revoked code grant refused on the batch path

fapihttp

  • TestFetchRejectsHostResolvingToNoAddresses: a resolver that returns zero IPs gives ErrSSRFBlocked before any round trip

internal/requestobject, internal/jarm

  • TestVerifyBoundsFutureNotBefore (both packages): an nbf more than MaxClockSkew ahead is ErrNotYetValid; one within the skew is accepted
  • TestParseClaimsRejectsMalformedOptionalClaims: a wrongly typed or empty jti or sub, and a non-numeric nbf, are ErrMalformedClaims

internal/jwe

  • TestOpenCBCHMACRejectsWrongIVSizeWithValidTag: a wrong-length IV with a tag that matches it is ErrDecryptionFailed, not a panic in cipher.NewCBCDecrypter

🤖 Generated with Claude Code

@codecov

codecov Bot commented Nov 8, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Add tests for verification checks that no existing test failed
without:

- ID token whose aud names only trusted audiences, never the client,
  with and without azp, is refused (ErrAudienceMismatch)
- JARM responses signed with the wrong key, or with the wrong iss or
  aud, expired, or exp beyond MaxJARMResponseLifetime, are refused
- JARM and request-object nbf more than MaxClockSkew in the future is
  refused; nbf within the skew is accepted
- request-object jti, sub and nbf of the wrong type or empty are
  ErrMalformedClaims
- resource: a pairwise lookup returning no subject and no error is a
  500
- resource: a code_grant_id-only token's revoked code grant is
  refused with a RevocationBatchChecker as without one
- client CIBA poll refuses token_type Bearer under DPoP
- client AssuranceProduction refuses non-Durable custody for Keys and
  Decryption
- client config: invalid ID token / UserInfo encryption algorithms,
  missing JARM algorithm, zero or over-60-minute request object
  lifetime (60 minutes accepted), zero MaxJARMResponseLifetime each
  refused with its own error
- fapihttp: a host resolving to no addresses is ErrSSRFBlocked before
  any round trip
- jwe: A256CBC-HS512 with a wrong-length IV and a matching tag is
  ErrDecryptionFailed, not a panic

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@osanderson
osanderson force-pushed the test/client-resource-crypto-coverage-gaps branch from 888072a to 100663d Compare November 8, 2026 23:14
@sonarqubecloud

sonarqubecloud Bot commented Nov 8, 2026

Copy link
Copy Markdown

@osanderson
osanderson merged commit 327700d into main Nov 8, 2026
27 checks passed
@osanderson
osanderson deleted the test/client-resource-crypto-coverage-gaps branch November 8, 2026 23:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant