Repository navigation
Add regression test for require* claims with jjwt-gson - #1083
Open
kimseongchan0914 wants to merge 1 commit into
Open
kimseongchan0914 wants to merge 1 commit into
kimseongchan0914 wants to merge 1 commit into
Conversation
Gson's default number handling deserialized all JSON numbers as Double, causing JwtParserBuilder require* assertions to fail (e.g. "Expected intClaim claim to be: 42, but was: 42.0."). This was resolved by jwtk#1009, which configures the default Gson instance with ToNumberPolicy.LONG_OR_DOUBLE. This test guards against regressions. Fixes jwtk#762 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #762
Summary
#762 reported that the
JwtParserBuilderrequire*methods failed when usingjjwt-gson. Gson's default number handling deserialized every JSON number as aDouble, so a claim like42came back as42.0and didn't match the expected value.That root cause appears to have been fixed by #1009 (resolving #771). It configures
GsonSerializer.DEFAULT_GSON, whichGsonDeserializeralso uses, withToNumberPolicy.LONG_OR_DOUBLE. However, #762 is still open and there is no test covering this scenario end-to-end.This PR adds
Issue762Test, modeled on the reproducer from the issue. It builds a compressed JWS withGsonSerializer, parses it withGsonDeserializer, and asserts that all of the following succeed:requireSubject,requireIssuer,requireAudience,requireIdrequireExpiration,requireNotBefore,requireIssuedAtrequire(...)with aString, anintand along(Long.MAX_VALUE) claimTesting
./mvnw -pl impl test -Dtest=Issue762Test: passes.new Gson()(the pre-Default Gson instance number strategy #1009 behavior), the test fails withIncorrectClaimException: Expected intClaim claim to be: 42, but was: 42.0., which confirms it catches the original bug../mvnw -pl impl license:check: passes.🤖 Generated with Claude Code