@@ -241,6 +241,34 @@ public void shouldGetLargeInstantWhenParsingNumericNode() {
241241 assertThat (instant .toEpochMilli (), is (2147493647L * 1000 ));
242242 }
243243
244+ // https://github.com/auth0/java-jwt/issues/706 - a NumericDate may be written in scientific
245+ // notation. An in-range value must still resolve to the right instant.
246+ @ Test
247+ public void shouldGetInstantWhenParsingScientificNotationNode () {
248+ Map <String , JsonNode > tree = new HashMap <>();
249+ DoubleNode node = new DoubleNode (1.7e9 );
250+ tree .put ("key" , node );
251+
252+ Instant instant = deserializer .getInstantFromSeconds (tree , "key" );
253+ assertThat (instant , is (notNullValue ()));
254+ assertThat (instant , is (Instant .ofEpochSecond (1_700_000_000L )));
255+ }
256+
257+ // A numeric value that does not fit a long (the exact value reported in issue #706) must be
258+ // rejected as out of range, not mislabeled as non-numeric.
259+ @ Test
260+ public void shouldThrowOutOfRangeWhenNumericDateExceedsLong () {
261+ exception .expect (JWTDecodeException .class );
262+ exception .expectMessage (
263+ "The claim 'key' value (1.733162101E26) is out of the range representable as a NumericDate." );
264+
265+ Map <String , JsonNode > tree = new HashMap <>();
266+ DoubleNode node = new DoubleNode (1.733162101e+26 );
267+ tree .put ("key" , node );
268+
269+ deserializer .getInstantFromSeconds (tree , "key" );
270+ }
271+
244272 @ Test
245273 public void shouldGetNullStringWhenParsingNullNode () {
246274 Map <String , JsonNode > tree = new HashMap <>();
0 commit comments