Skip to content

test(auth): Assert JWT headers and claims (alg, typ, iat, exp)#13472

Merged
westarle merged 2 commits into
googleapis:mainfrom
westarle:fix-test-gap-jwt-headers
Jun 16, 2026
Merged

test(auth): Assert JWT headers and claims (alg, typ, iat, exp)#13472
westarle merged 2 commits into
googleapis:mainfrom
westarle:fix-test-gap-jwt-headers

Conversation

@westarle

Copy link
Copy Markdown
Contributor

This commit adds explicit assertions to verify that the generated JWS header correctly contains 'alg=RS256' and 'typ=JWT', and that the JWT payload contains the 'iat' and 'exp' claims with exactly a 3600-second (1-hour) expiration offset.

This brings the Java library's test suite into alignment with the expected auth specification. Other Google Cloud client libraries like Go, Node.js, and Python natively assert the presence of these standard headers and the 1-hour expiration window during their Self-Signed JWT generation tests.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds assertions to verify JWT header and payload claims (such as algorithm, type, issued-at, and expiration times) in ServiceAccountCredentialsTest and ServiceAccountJwtAccessCredentialsTest. The review feedback suggests using type-safe getters getIssuedAtTimeSeconds() and getExpirationTimeSeconds() from JsonWebToken.Payload instead of generic map lookups and casting to Long to avoid potential ClassCastException issues.

@westarle westarle force-pushed the fix-test-gap-jwt-headers branch from d169852 to ccf8399 Compare June 16, 2026 10:48
This commit adds explicit assertions to verify that the generated JWS header correctly contains 'alg=RS256' and 'typ=JWT', and that the JWT payload contains the 'iat' and 'exp' claims with exactly a 3600-second (1-hour) expiration offset.

This brings the Java library's test suite into alignment with the expected auth specification. Other Google Cloud client libraries like Go, Node.js, and Python natively assert the presence of these standard headers and the 1-hour expiration window during their Self-Signed JWT generation tests.
@westarle westarle force-pushed the fix-test-gap-jwt-headers branch from ccf8399 to dd6a9e7 Compare June 16, 2026 11:02
@westarle westarle marked this pull request as ready for review June 16, 2026 11:24
@westarle westarle requested review from a team as code owners June 16, 2026 11:24
@westarle westarle enabled auto-merge (squash) June 16, 2026 11:25
@westarle westarle merged commit 2204d75 into googleapis:main Jun 16, 2026
289 of 294 checks passed
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