amogh-jahagirdar commented on code in PR #8365:
URL: https://github.com/apache/iceberg/pull/8365#discussion_r1303539488


##########
aws/src/main/java/org/apache/iceberg/aws/s3/signer/S3V4RestSignerClient.java:
##########
@@ -328,6 +334,27 @@ public SdkHttpFullRequest sign(
     return mutableRequest.build();
   }
 
+  /**
+   * Only add body for DeleteObjectsRequest. Refer to
+   * 
https://docs.aws.amazon.com/AmazonS3/latest/API/API_DeleteObjects.html#API_DeleteObjects_RequestSyntax
+   */
+  private String body(SdkHttpFullRequest request) {
+    if (isDeleteObjectsRequest(request) && 
request.contentStreamProvider().isPresent()) {
+      try (InputStream is = request.contentStreamProvider().get().newStream()) 
{
+        return IoUtils.toUtf8String(is);
+      } catch (IOException e) {
+        throw new UncheckedIOException("Failed to set body for S3 sign 
request", e);
+      }
+    }
+
+    return null;
+  }
+
+  private boolean isDeleteObjectsRequest(SdkHttpFullRequest request) {
+    return request.method() == SdkHttpMethod.POST
+        && request.rawQueryParameters().containsKey("delete");

Review Comment:
   I wasn't able to find anything either (referencing 
https://docs.aws.amazon.com/AmazonS3/latest/API/API_Operations_Amazon_Simple_Storage_Service.html)
 , I'll do a double pass and also see if there's even more specific criteria 
for bulk deletes beyond the method type and query parameter.



##########
aws/src/test/java/org/apache/iceberg/aws/s3/signer/S3SignerServlet.java:
##########
@@ -78,10 +81,42 @@ public class S3SignerServlet extends HttpServlet {
       ImmutableMap.of(HttpHeaders.CONTENT_TYPE, 
ContentType.APPLICATION_JSON.getMimeType());
   private final ObjectMapper mapper;
 
+  private List<SignRequestValidator> s3SignRequestValidators = 
Lists.newArrayList();
+
+  /**
+   * SignRequestValidator is a wrapper class used for validating the contents 
of the S3SignRequest
+   * and thus verifying the behavior of the client during testing.
+   */
+  public static class SignRequestValidator {
+    private final Predicate<S3SignRequest> verifyExpectation;
+    private final Predicate<S3SignRequest> signRequestExpectation;
+    private final String assertMessage;
+
+    public SignRequestValidator(
+        Predicate<S3SignRequest> signRequestExpectation,
+        Predicate<S3SignRequest> verifyExpectation,
+        String assertMessage) {
+      this.signRequestExpectation = signRequestExpectation;
+      this.verifyExpectation = verifyExpectation;
+      this.assertMessage = assertMessage;
+    }
+
+    void validateRequest(S3SignRequest request) {
+      if (verifyExpectation.test(request)) {
+        Assert.assertTrue(assertMessage, signRequestExpectation.test(request));

Review Comment:
   good catch, I missed this. Will fix



##########
aws/src/test/java/org/apache/iceberg/aws/s3/signer/S3SignerServlet.java:
##########
@@ -78,10 +81,42 @@ public class S3SignerServlet extends HttpServlet {
       ImmutableMap.of(HttpHeaders.CONTENT_TYPE, 
ContentType.APPLICATION_JSON.getMimeType());
   private final ObjectMapper mapper;
 
+  private List<SignRequestValidator> s3SignRequestValidators = 
Lists.newArrayList();
+
+  /**
+   * SignRequestValidator is a wrapper class used for validating the contents 
of the S3SignRequest
+   * and thus verifying the behavior of the client during testing.
+   */
+  public static class SignRequestValidator {
+    private final Predicate<S3SignRequest> verifyExpectation;
+    private final Predicate<S3SignRequest> signRequestExpectation;

Review Comment:
   I agree, I like `requestMatcher` and `requestExpectation`. Both are concise 
and convey the intent of the variable



-- 
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