Russole commented on code in PR #9371:
URL: https://github.com/apache/ozone/pull/9371#discussion_r2571658052


##########
hadoop-ozone/s3gateway/src/test/java/org/apache/hadoop/ozone/s3/endpoint/TestBucketPut.java:
##########
@@ -51,16 +80,36 @@ public void setup() throws Exception {
     bucketEndpoint = EndpointBuilder.newBucketEndpointBuilder()
         .setClient(clientStub)
         .build();
+
+    mockHeaders = mock(HttpHeaders.class);
+    bucketEndpoint.setHeaders(mockHeaders);
+  }
+
+  @Test
+  public void testAclWithMissingHeaders() throws Exception {
+    bucketEndpoint.getClient().getObjectStore().createS3Bucket(bucketName);
+
+    InputStream body = new 
ByteArrayInputStream(VALID_ACL_XML.getBytes(StandardCharsets.UTF_8));
+
+    Response resp = bucketEndpoint.put(bucketName, "acl", body);
+    Assertions.assertEquals(200, resp.getStatus());
   }
 
   @Test
-  public void testBucketFailWithAuthHeaderMissing() throws Exception {
-    try {
-      bucketEndpoint.put(bucketName, null, null);
-    } catch (OS3Exception ex) {
-      assertEquals(HTTP_NOT_FOUND, ex.getHttpCode());
-      assertEquals(MALFORMED_HEADER.getCode(), ex.getCode());
-    }
+  public void testAclWithMissingHeadersAndNoBody() throws Exception {
+    bucketEndpoint.getClient().getObjectStore().createS3Bucket(bucketName);
+
+    WebApplicationException wae = assertThrows(WebApplicationException.class,
+        () -> bucketEndpoint.put(bucketName, "acl", null));
+
+    Throwable cause = wae.getCause();
+    assertNotNull(cause);
+    assertTrue(cause instanceof OS3Exception);
+
+    OS3Exception os3 = (OS3Exception) cause;
+
+    assertEquals("InvalidRequest", os3.getCode());
+    assertEquals(400, os3.getHttpCode());

Review Comment:
   Thanks for the suggestion. I've updated the code to use constant references 
consistently.



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