Skip to content

test: remove live Google JWKS call from JwtBearerTokenTest (2.42)#24487

Merged
netroms merged 1 commit into
2.42from
jwt-test-offline_2.42
Jul 20, 2026
Merged

test: remove live Google JWKS call from JwtBearerTokenTest (2.42)#24487
netroms merged 1 commit into
2.42from
jwt-test-offline_2.42

Conversation

@netroms

@netroms netroms commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Backport of #24486 to this line.

Summary

JwtBearerTokenTest.testExpiredToken cleared the local JwtDecoder and replayed a real (long-expired) Google id_token, forcing JwtDecoders.fromIssuerLocation to perform live OIDC discovery plus a JWKS fetch of https://www.googleapis.com/oauth2/v3/certs on every CI run. Any egress blip failed the build:

JwtBearerTokenTest.testExpiredToken ... com.nimbusds.jose.RemoteKeySourceException:
  I/O error on GET request for "https://www.googleapis.com/oauth2/v3/certs": Connection reset

External requests do not belong in the automated CI build.

What changed (test-only)

  • testExpiredToken now mints a locally-signed token with a fixed past exp and asserts the actual expiry error (Jwt expired at …). Previously the asserted message was a key-not-found error caused by Google having long rotated the 2021 signing key out of its JWKS — token expiry was never actually exercised.
  • New testUnknownSigningKey preserves the original intent (a token signed with a key the server no longer accepts, e.g. ephemeral signing keys after a restart) fully offline: an RS384-signed token against the RS256 local decoder produces the same error message the old test relied on Google's key rotation to trigger.
  • Removed the now-unused Google token, client id, and provider setup.

No production code affected.

Verification

  • Reproduced first: with network egress blocked, the old test fails with the CI error (I/O error on GET request for "https://accounts.google.com/.well-known/openid-configuration").
  • After the change: the full test class passes 7/7 both with egress blocked and with normal network, proving zero external calls remain.

AI Assisted

JwtBearerTokenTest.testExpiredToken cleared the local JwtDecoder and
replayed a real (long-expired) Google id_token, forcing
JwtDecoders.fromIssuerLocation to perform live OIDC discovery and a
JWKS fetch of https://www.googleapis.com/oauth2/v3/certs on every CI
run. Any egress blip failed the build (RemoteKeySourceException).

Rewrite the test to run fully offline using the existing local RSA
fixtures: testExpiredToken now mints a locally-signed token with a
fixed past exp and asserts the actual expiry error, and a new
testUnknownSigningKey preserves the original intent (token signed
with a key/algorithm the server does not accept) by signing with
RS384 against the RS256 decoder, asserting the same error message the
old test relied on Google's key rotation to produce. The unused
Google token, client id and provider setup are removed. Test-only
change; no production code affected.
@sonarqubecloud

Copy link
Copy Markdown

@netroms
netroms merged commit a12e280 into 2.42 Jul 20, 2026
14 checks passed
@netroms
netroms deleted the jwt-test-offline_2.42 branch July 20, 2026 13:41
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.

2 participants