jojochuang commented on code in PR #8826:
URL: https://github.com/apache/ozone/pull/8826#discussion_r2216979886


##########
hadoop-ozone/integration-test-s3/src/test/java/org/apache/hadoop/ozone/s3/awssdk/v2/AbstractS3SDKV2Tests.java:
##########
@@ -507,6 +511,97 @@ public void testPresignedUrlGet() throws Exception {
     }
   }
 
+  @Test
+  public void testPresignedUrlHead() throws Exception {
+    final String bucketName = getBucketName();
+    final String keyName = getKeyName();
+    final String content = "bar";
+    s3Client.createBucket(b -> b.bucket(bucketName));
+
+    s3Client.putObject(b -> b
+            .bucket(bucketName)
+            .key(keyName),
+        RequestBody.fromString(content));
+
+    try (S3Presigner presigner = S3Presigner.builder()
+        // TODO: Find a way to retrieve the path style configuration from 
S3Client instead
+        
.serviceConfiguration(S3Configuration.builder().pathStyleAccessEnabled(true).build())
+        
.endpointOverride(s3Client.serviceClientConfiguration().endpointOverride().get())
+        .region(s3Client.serviceClientConfiguration().region())
+        
.credentialsProvider(s3Client.serviceClientConfiguration().credentialsProvider()).build())
 {
+
+      HeadObjectRequest objectRequest = HeadObjectRequest.builder()
+          .bucket(bucketName)
+          .key(keyName)
+          .build();
+
+      HeadObjectPresignRequest presignRequest = 
HeadObjectPresignRequest.builder()
+          .signatureDuration(Duration.ofMinutes(10))
+          .headObjectRequest(objectRequest)
+          .build();
+
+      PresignedHeadObjectRequest presignedRequest = 
presigner.presignHeadObject(presignRequest);
+
+      URL presignedUrl = presignedRequest.url();
+      HttpURLConnection connection = (HttpURLConnection) 
presignedUrl.openConnection();

Review Comment:
   connection and bucketConnection objects should be closed explicitly at the 
end of test



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