timothyw553 commented on code in PR #18785:
URL: https://github.com/apache/iceberg/pull/18785#discussion_r4720030171


##########
core/src/test/java/org/apache/iceberg/rest/auth/TestOAuth2Util.java:
##########
@@ -107,6 +107,13 @@ public void testExpiresAt() {
     assertThat(OAuth2Util.expiresAtMillis(token)).isNull();
   }
 
+  @Test
+  void expiresAtWithFractionalExp() {
+    String token =
+        new PlainJWT(new JWTClaimsSet.Builder().claim("exp", 
19999999999.5).build()).serialize();
+    assertThat(OAuth2Util.expiresAtMillis(token)).isEqualTo(19999999999500L);
+  }

Review Comment:
   this only checks a valid fractional number, so removing `!exp.isNumber()` 
would convert non-numeric `exp` claims to `0L` and still pass all existing 
tests. could we add a parameterized test for non-numeric types like strings, 
booleans, objects, and arrays?
   
   ```diff
   +  @ParameterizedTest
   +  @ValueSource(strings = {"\"1767225600.5\"", "true", "{}", "[]"})
   +  void expiresAtWithNonNumericExp(String exp) {
   +    String payload = "{\"exp\":" + exp + "}";
   +    String token =
   +        "e30."
   +            + Base64.getUrlEncoder()
   +                .withoutPadding()
   +                .encodeToString(payload.getBytes(StandardCharsets.UTF_8))
   +            + ".";
   +
   +    assertThat(OAuth2Util.expiresAtMillis(token)).isNull();
   +  }
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to