From 2d243931ce7cb020ccd90ffaca8111b2e96a5c5c Mon Sep 17 00:00:00 2001 From: Russole <850905junior@gmail.com> Date: Mon, 24 Nov 2025 22:09:49 +0800 Subject: [PATCH 01/16] HDDS-13932. Fix TestBucketPut by correcting test logic and updating test cases --- .../ozone/s3/endpoint/TestBucketPut.java | 141 +++++++++++++++--- 1 file changed, 124 insertions(+), 17 deletions(-) diff --git a/hadoop-ozone/s3gateway/src/test/java/org/apache/hadoop/ozone/s3/endpoint/TestBucketPut.java b/hadoop-ozone/s3gateway/src/test/java/org/apache/hadoop/ozone/s3/endpoint/TestBucketPut.java index 0464ff54edca..575d4c24d9e0 100644 --- a/hadoop-ozone/s3gateway/src/test/java/org/apache/hadoop/ozone/s3/endpoint/TestBucketPut.java +++ b/hadoop-ozone/s3gateway/src/test/java/org/apache/hadoop/ozone/s3/endpoint/TestBucketPut.java @@ -19,17 +19,26 @@ import static java.net.HttpURLConnection.HTTP_CONFLICT; import static java.net.HttpURLConnection.HTTP_NOT_FOUND; -import static org.apache.hadoop.ozone.s3.exception.S3ErrorTable.BUCKET_ALREADY_EXISTS; -import static org.apache.hadoop.ozone.s3.exception.S3ErrorTable.MALFORMED_HEADER; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; +import java.io.ByteArrayInputStream; +import java.io.InputStream; +import java.lang.reflect.Field; +import java.nio.charset.StandardCharsets; +import javax.ws.rs.WebApplicationException; +import javax.ws.rs.core.HttpHeaders; import javax.ws.rs.core.Response; import org.apache.hadoop.ozone.OzoneConsts; import org.apache.hadoop.ozone.client.OzoneClient; import org.apache.hadoop.ozone.client.OzoneClientStub; import org.apache.hadoop.ozone.s3.exception.OS3Exception; +import org.apache.hadoop.ozone.s3.exception.S3ErrorTable; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -40,6 +49,24 @@ public class TestBucketPut { private String bucketName = OzoneConsts.BUCKET; private BucketEndpoint bucketEndpoint; + private HttpHeaders mockHeaders; + private static final String VALID_ACL_XML = + "" + + " " + + " owner-id" + + " owner-name" + + " " + + " " + + " " + + " " + + " owner-id" + + " owner-name" + + " " + + " FULL_CONTROL" + + " " + + " " + + ""; @BeforeEach public void setup() throws Exception { @@ -51,16 +78,52 @@ public void setup() throws Exception { bucketEndpoint = EndpointBuilder.newBucketEndpointBuilder() .setClient(clientStub) .build(); + + mockHeaders = mock(HttpHeaders.class); + bucketEndpoint.setHeaders(mockHeaders); + + Class clazz = bucketEndpoint.getClass(); + Field headersField = null; + while (clazz != null) { + try { + headersField = clazz.getDeclaredField("headers"); + break; + } catch (NoSuchFieldException e) { + clazz = clazz.getSuperclass(); + } + } + if (headersField == null) { + throw new IllegalStateException("Field 'headers' not found on BucketEndpoint hierarchy"); + } + headersField.setAccessible(true); + headersField.set(bucketEndpoint, mockHeaders); } @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 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 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()); } @Test @@ -73,16 +136,60 @@ public void testBucketPut() throws Exception { OS3Exception e = assertThrows(OS3Exception.class, () -> bucketEndpoint.put( bucketName, null, null)); assertEquals(HTTP_CONFLICT, e.getHttpCode()); - assertEquals(BUCKET_ALREADY_EXISTS.getCode(), e.getCode()); + assertEquals(S3ErrorTable.BUCKET_ALREADY_EXISTS.getCode(), e.getCode()); } @Test - public void testBucketFailWithInvalidHeader() 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 testPutAclOnNonExistingBucket() throws Exception { + OS3Exception e = assertThrows(OS3Exception.class, + () -> bucketEndpoint.put(bucketName, "acl", null)); + assertEquals(HTTP_NOT_FOUND, e.getHttpCode()); + assertEquals(S3ErrorTable.NO_SUCH_BUCKET.getCode(), e.getCode()); } + + @Test + public void testPutAclWithGrantFullControlHeader() throws Exception { + bucketEndpoint.getClient().getObjectStore().createS3Bucket(bucketName); + + when(mockHeaders.getHeaderString(S3Acl.GRANT_FULL_CONTROL)) + .thenReturn("id=\"owner-id\""); + + Response resp = bucketEndpoint.put(bucketName, "acl", null); + + assertEquals(200, resp.getStatus()); + } + + @Test + public void testPutAclWithInvalidXmlBody() throws Exception { + bucketEndpoint.getClient().getObjectStore().createS3Bucket(bucketName); + + InputStream body = new ByteArrayInputStream( + "not-xml".getBytes(StandardCharsets.UTF_8)); + + WebApplicationException wae = assertThrows(WebApplicationException.class, + () -> bucketEndpoint.put(bucketName, "acl", body)); + + Throwable cause = wae.getCause(); + assertNotNull(cause); + assertTrue(cause instanceof OS3Exception); + OS3Exception os3 = (OS3Exception) cause; + + assertEquals("InvalidRequest", os3.getCode()); + assertEquals(400, os3.getHttpCode()); + } + + @Test + public void testPutAclWithMalformedGrantHeader() throws Exception { + bucketEndpoint.getClient().getObjectStore().createS3Bucket(bucketName); + + when(mockHeaders.getHeaderString(S3Acl.GRANT_FULL_CONTROL)) + .thenReturn("id\"owner-id\""); + + OS3Exception ex = assertThrows(OS3Exception.class, + () -> bucketEndpoint.put(bucketName, "acl", null)); + + assertEquals(S3ErrorTable.INVALID_ARGUMENT.getCode(), ex.getCode()); + assertEquals(400, ex.getHttpCode()); + } + } From 1d5e9a10a8ec71c2d4341ad747eba4f114421886 Mon Sep 17 00:00:00 2001 From: Russole <850905junior@gmail.com> Date: Tue, 25 Nov 2025 21:35:19 +0800 Subject: [PATCH 02/16] Clean TestBucketPut Setup() Part --- .../hadoop/ozone/s3/endpoint/TestBucketPut.java | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/hadoop-ozone/s3gateway/src/test/java/org/apache/hadoop/ozone/s3/endpoint/TestBucketPut.java b/hadoop-ozone/s3gateway/src/test/java/org/apache/hadoop/ozone/s3/endpoint/TestBucketPut.java index 575d4c24d9e0..6c8e8d81c2ea 100644 --- a/hadoop-ozone/s3gateway/src/test/java/org/apache/hadoop/ozone/s3/endpoint/TestBucketPut.java +++ b/hadoop-ozone/s3gateway/src/test/java/org/apache/hadoop/ozone/s3/endpoint/TestBucketPut.java @@ -81,22 +81,6 @@ public void setup() throws Exception { mockHeaders = mock(HttpHeaders.class); bucketEndpoint.setHeaders(mockHeaders); - - Class clazz = bucketEndpoint.getClass(); - Field headersField = null; - while (clazz != null) { - try { - headersField = clazz.getDeclaredField("headers"); - break; - } catch (NoSuchFieldException e) { - clazz = clazz.getSuperclass(); - } - } - if (headersField == null) { - throw new IllegalStateException("Field 'headers' not found on BucketEndpoint hierarchy"); - } - headersField.setAccessible(true); - headersField.set(bucketEndpoint, mockHeaders); } @Test From ce0facd83de82380b069f7bd3147ae23d692fb16 Mon Sep 17 00:00:00 2001 From: Russole <850905junior@gmail.com> Date: Wed, 26 Nov 2025 00:31:18 +0800 Subject: [PATCH 03/16] Fix Unused Import --- .../java/org/apache/hadoop/ozone/s3/endpoint/TestBucketPut.java | 1 - 1 file changed, 1 deletion(-) diff --git a/hadoop-ozone/s3gateway/src/test/java/org/apache/hadoop/ozone/s3/endpoint/TestBucketPut.java b/hadoop-ozone/s3gateway/src/test/java/org/apache/hadoop/ozone/s3/endpoint/TestBucketPut.java index 6c8e8d81c2ea..c3ee62da72d8 100644 --- a/hadoop-ozone/s3gateway/src/test/java/org/apache/hadoop/ozone/s3/endpoint/TestBucketPut.java +++ b/hadoop-ozone/s3gateway/src/test/java/org/apache/hadoop/ozone/s3/endpoint/TestBucketPut.java @@ -28,7 +28,6 @@ import java.io.ByteArrayInputStream; import java.io.InputStream; -import java.lang.reflect.Field; import java.nio.charset.StandardCharsets; import javax.ws.rs.WebApplicationException; import javax.ws.rs.core.HttpHeaders; From 230f88e619257772bbc0c36f3d3a6371769519be Mon Sep 17 00:00:00 2001 From: Russole <850905junior@gmail.com> Date: Wed, 26 Nov 2025 02:34:30 +0800 Subject: [PATCH 04/16] Ensure consistent usage of assertEquals() in TestBucketPut tests --- .../hadoop/ozone/s3/endpoint/TestBucketPut.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/hadoop-ozone/s3gateway/src/test/java/org/apache/hadoop/ozone/s3/endpoint/TestBucketPut.java b/hadoop-ozone/s3gateway/src/test/java/org/apache/hadoop/ozone/s3/endpoint/TestBucketPut.java index c3ee62da72d8..48280cd6644e 100644 --- a/hadoop-ozone/s3gateway/src/test/java/org/apache/hadoop/ozone/s3/endpoint/TestBucketPut.java +++ b/hadoop-ozone/s3gateway/src/test/java/org/apache/hadoop/ozone/s3/endpoint/TestBucketPut.java @@ -19,6 +19,10 @@ import static java.net.HttpURLConnection.HTTP_CONFLICT; import static java.net.HttpURLConnection.HTTP_NOT_FOUND; +import static org.apache.hadoop.ozone.s3.exception.S3ErrorTable.BUCKET_ALREADY_EXISTS; +import static org.apache.hadoop.ozone.s3.exception.S3ErrorTable.INVALID_ARGUMENT; +import static org.apache.hadoop.ozone.s3.exception.S3ErrorTable.INVALID_REQUEST; +import static org.apache.hadoop.ozone.s3.exception.S3ErrorTable.NO_SUCH_BUCKET; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertThrows; @@ -36,7 +40,6 @@ import org.apache.hadoop.ozone.client.OzoneClient; import org.apache.hadoop.ozone.client.OzoneClientStub; import org.apache.hadoop.ozone.s3.exception.OS3Exception; -import org.apache.hadoop.ozone.s3.exception.S3ErrorTable; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -118,16 +121,16 @@ public void testBucketPut() throws Exception { // Create-bucket on an existing bucket fails OS3Exception e = assertThrows(OS3Exception.class, () -> bucketEndpoint.put( bucketName, null, null)); + assertEquals(BUCKET_ALREADY_EXISTS.getCode(), e.getCode()); assertEquals(HTTP_CONFLICT, e.getHttpCode()); - assertEquals(S3ErrorTable.BUCKET_ALREADY_EXISTS.getCode(), e.getCode()); } @Test public void testPutAclOnNonExistingBucket() throws Exception { OS3Exception e = assertThrows(OS3Exception.class, () -> bucketEndpoint.put(bucketName, "acl", null)); + assertEquals(NO_SUCH_BUCKET.getCode(), e.getCode()); assertEquals(HTTP_NOT_FOUND, e.getHttpCode()); - assertEquals(S3ErrorTable.NO_SUCH_BUCKET.getCode(), e.getCode()); } @Test @@ -157,7 +160,7 @@ public void testPutAclWithInvalidXmlBody() throws Exception { assertTrue(cause instanceof OS3Exception); OS3Exception os3 = (OS3Exception) cause; - assertEquals("InvalidRequest", os3.getCode()); + assertEquals(INVALID_REQUEST.getCode(), os3.getCode()); assertEquals(400, os3.getHttpCode()); } @@ -171,7 +174,7 @@ public void testPutAclWithMalformedGrantHeader() throws Exception { OS3Exception ex = assertThrows(OS3Exception.class, () -> bucketEndpoint.put(bucketName, "acl", null)); - assertEquals(S3ErrorTable.INVALID_ARGUMENT.getCode(), ex.getCode()); + assertEquals(INVALID_ARGUMENT.getCode(), ex.getCode()); assertEquals(400, ex.getHttpCode()); } From 41b7a9178b2117215f03beac32e93aceb68ccd5e Mon Sep 17 00:00:00 2001 From: Russole <850905junior@gmail.com> Date: Thu, 27 Nov 2025 22:40:24 +0800 Subject: [PATCH 05/16] Use INVALID_REQUEST.getCode() instead of inline string InvalidRequest --- .../java/org/apache/hadoop/ozone/s3/endpoint/TestBucketPut.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hadoop-ozone/s3gateway/src/test/java/org/apache/hadoop/ozone/s3/endpoint/TestBucketPut.java b/hadoop-ozone/s3gateway/src/test/java/org/apache/hadoop/ozone/s3/endpoint/TestBucketPut.java index 48280cd6644e..791c93c3a452 100644 --- a/hadoop-ozone/s3gateway/src/test/java/org/apache/hadoop/ozone/s3/endpoint/TestBucketPut.java +++ b/hadoop-ozone/s3gateway/src/test/java/org/apache/hadoop/ozone/s3/endpoint/TestBucketPut.java @@ -108,7 +108,7 @@ public void testAclWithMissingHeadersAndNoBody() throws Exception { OS3Exception os3 = (OS3Exception) cause; - assertEquals("InvalidRequest", os3.getCode()); + assertEquals(INVALID_REQUEST.getCode(), os3.getCode()); assertEquals(400, os3.getHttpCode()); } From 543f78a76358c348cd84ff2db24b37db398fef71 Mon Sep 17 00:00:00 2001 From: Russole <850905junior@gmail.com> Date: Thu, 27 Nov 2025 23:37:14 +0800 Subject: [PATCH 06/16] Add testPutAclWithBothHeadersAndBody in TestBucketPut --- .../ozone/s3/endpoint/TestBucketPut.java | 38 +++++++++++++++++-- 1 file changed, 34 insertions(+), 4 deletions(-) diff --git a/hadoop-ozone/s3gateway/src/test/java/org/apache/hadoop/ozone/s3/endpoint/TestBucketPut.java b/hadoop-ozone/s3gateway/src/test/java/org/apache/hadoop/ozone/s3/endpoint/TestBucketPut.java index 791c93c3a452..4a01c6be2d79 100644 --- a/hadoop-ozone/s3gateway/src/test/java/org/apache/hadoop/ozone/s3/endpoint/TestBucketPut.java +++ b/hadoop-ozone/s3gateway/src/test/java/org/apache/hadoop/ozone/s3/endpoint/TestBucketPut.java @@ -19,24 +19,25 @@ import static java.net.HttpURLConnection.HTTP_CONFLICT; import static java.net.HttpURLConnection.HTTP_NOT_FOUND; +import static org.apache.hadoop.ozone.OzoneAcl.AclScope.ACCESS; import static org.apache.hadoop.ozone.s3.exception.S3ErrorTable.BUCKET_ALREADY_EXISTS; import static org.apache.hadoop.ozone.s3.exception.S3ErrorTable.INVALID_ARGUMENT; import static org.apache.hadoop.ozone.s3.exception.S3ErrorTable.INVALID_REQUEST; import static org.apache.hadoop.ozone.s3.exception.S3ErrorTable.NO_SUCH_BUCKET; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertThrows; -import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.*; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; import java.io.ByteArrayInputStream; import java.io.InputStream; import java.nio.charset.StandardCharsets; +import java.util.List; import javax.ws.rs.WebApplicationException; import javax.ws.rs.core.HttpHeaders; import javax.ws.rs.core.Response; +import org.apache.hadoop.ozone.OzoneAcl; import org.apache.hadoop.ozone.OzoneConsts; +import org.apache.hadoop.ozone.client.OzoneBucket; import org.apache.hadoop.ozone.client.OzoneClient; import org.apache.hadoop.ozone.client.OzoneClientStub; import org.apache.hadoop.ozone.s3.exception.OS3Exception; @@ -178,4 +179,33 @@ public void testPutAclWithMalformedGrantHeader() throws Exception { assertEquals(400, ex.getHttpCode()); } + @Test + public void testPutAclWithBothHeadersAndBody() throws Exception { + bucketEndpoint.getClient().getObjectStore().createS3Bucket(bucketName); + + // Header: READ + when(mockHeaders.getHeaderString(S3Acl.GRANT_READ)) + .thenReturn("id=owner-id"); + + // Body: FULL_CONTROL + InputStream body = new ByteArrayInputStream( + VALID_ACL_XML.getBytes(StandardCharsets.UTF_8)); + + Response resp = bucketEndpoint.put(bucketName, "acl", body); + assertEquals(200, resp.getStatus()); + + OzoneBucket bucket = bucketEndpoint.getClient() + .getObjectStore() + .getS3Bucket(bucketName); + + List acls = bucket.getAcls(); + assertFalse(acls.isEmpty()); + + OzoneAcl ownerAcl = acls.stream() + .filter(acl -> "owner-id".equals(acl.getName()) + && acl.getAclScope() == ACCESS) + .findFirst() + .orElseThrow(() -> new AssertionError("owner-id ACL not found")); + } + } From a20de05c315b96975d6b5be9a5eb209cb4692076 Mon Sep 17 00:00:00 2001 From: Russole <850905junior@gmail.com> Date: Fri, 28 Nov 2025 00:55:15 +0800 Subject: [PATCH 07/16] Add testPutAclWithEmptyGrantHeaderValue and testPutAclWithWhitespaceGrantHeaderValue in TestBucketPut --- .../ozone/s3/endpoint/TestBucketPut.java | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/hadoop-ozone/s3gateway/src/test/java/org/apache/hadoop/ozone/s3/endpoint/TestBucketPut.java b/hadoop-ozone/s3gateway/src/test/java/org/apache/hadoop/ozone/s3/endpoint/TestBucketPut.java index 4a01c6be2d79..88f19f2f271a 100644 --- a/hadoop-ozone/s3gateway/src/test/java/org/apache/hadoop/ozone/s3/endpoint/TestBucketPut.java +++ b/hadoop-ozone/s3gateway/src/test/java/org/apache/hadoop/ozone/s3/endpoint/TestBucketPut.java @@ -208,4 +208,29 @@ public void testPutAclWithBothHeadersAndBody() throws Exception { .orElseThrow(() -> new AssertionError("owner-id ACL not found")); } + @Test + public void testPutAclWithEmptyGrantHeaderValue() throws Exception { + bucketEndpoint.getClient().getObjectStore().createS3Bucket(bucketName); + + when(mockHeaders.getHeaderString(S3Acl.GRANT_FULL_CONTROL)) + .thenReturn(""); // empty + + Response resp = bucketEndpoint.put(bucketName, "acl", null); + + assertEquals(200, resp.getStatus()); + } + + @Test + public void testPutAclWithWhitespaceGrantHeaderValue() throws Exception { + bucketEndpoint.getClient().getObjectStore().createS3Bucket(bucketName); + + when(mockHeaders.getHeaderString(S3Acl.GRANT_FULL_CONTROL)) + .thenReturn(" "); // whitespace only + + OS3Exception ex = assertThrows(OS3Exception.class, + () -> bucketEndpoint.put(bucketName, "acl", null)); + + assertEquals(INVALID_ARGUMENT.getCode(), ex.getCode()); + assertEquals(400, ex.getHttpCode()); + } } From e0b3ca924600c165a848805573c90ef08acdd7e2 Mon Sep 17 00:00:00 2001 From: Russole <850905junior@gmail.com> Date: Fri, 28 Nov 2025 01:06:06 +0800 Subject: [PATCH 08/16] Fix CheckStyle --- .../ozone/s3/endpoint/TestBucketPut.java | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/hadoop-ozone/s3gateway/src/test/java/org/apache/hadoop/ozone/s3/endpoint/TestBucketPut.java b/hadoop-ozone/s3gateway/src/test/java/org/apache/hadoop/ozone/s3/endpoint/TestBucketPut.java index 88f19f2f271a..cc0118056df8 100644 --- a/hadoop-ozone/s3gateway/src/test/java/org/apache/hadoop/ozone/s3/endpoint/TestBucketPut.java +++ b/hadoop-ozone/s3gateway/src/test/java/org/apache/hadoop/ozone/s3/endpoint/TestBucketPut.java @@ -24,7 +24,11 @@ import static org.apache.hadoop.ozone.s3.exception.S3ErrorTable.INVALID_ARGUMENT; import static org.apache.hadoop.ozone.s3.exception.S3ErrorTable.INVALID_REQUEST; import static org.apache.hadoop.ozone.s3.exception.S3ErrorTable.NO_SUCH_BUCKET; -import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -93,7 +97,7 @@ public void testAclWithMissingHeaders() throws Exception { InputStream body = new ByteArrayInputStream(VALID_ACL_XML.getBytes(StandardCharsets.UTF_8)); Response resp = bucketEndpoint.put(bucketName, "acl", body); - Assertions.assertEquals(200, resp.getStatus()); + assertEquals(200, resp.getStatus()); } @Test @@ -194,14 +198,14 @@ public void testPutAclWithBothHeadersAndBody() throws Exception { Response resp = bucketEndpoint.put(bucketName, "acl", body); assertEquals(200, resp.getStatus()); - OzoneBucket bucket = bucketEndpoint.getClient() + OzoneBucket bucket = bucketEndpoint.getClient() .getObjectStore() .getS3Bucket(bucketName); - List acls = bucket.getAcls(); - assertFalse(acls.isEmpty()); + List acls = bucket.getAcls(); + assertFalse(acls.isEmpty()); - OzoneAcl ownerAcl = acls.stream() + OzoneAcl ownerAcl = acls.stream() .filter(acl -> "owner-id".equals(acl.getName()) && acl.getAclScope() == ACCESS) .findFirst() @@ -217,7 +221,7 @@ public void testPutAclWithEmptyGrantHeaderValue() throws Exception { Response resp = bucketEndpoint.put(bucketName, "acl", null); - assertEquals(200, resp.getStatus()); + Assertions.assertEquals(200, resp.getStatus()); } @Test @@ -230,7 +234,7 @@ public void testPutAclWithWhitespaceGrantHeaderValue() throws Exception { OS3Exception ex = assertThrows(OS3Exception.class, () -> bucketEndpoint.put(bucketName, "acl", null)); - assertEquals(INVALID_ARGUMENT.getCode(), ex.getCode()); - assertEquals(400, ex.getHttpCode()); + Assertions.assertEquals(INVALID_ARGUMENT.getCode(), ex.getCode()); + Assertions.assertEquals(400, ex.getHttpCode()); } } From e899b941a8fee08e1ff03f22ebabcde4746717e9 Mon Sep 17 00:00:00 2001 From: Russole <850905junior@gmail.com> Date: Fri, 28 Nov 2025 07:15:23 +0800 Subject: [PATCH 09/16] Fix DeadStore --- .../java/org/apache/hadoop/ozone/s3/endpoint/TestBucketPut.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hadoop-ozone/s3gateway/src/test/java/org/apache/hadoop/ozone/s3/endpoint/TestBucketPut.java b/hadoop-ozone/s3gateway/src/test/java/org/apache/hadoop/ozone/s3/endpoint/TestBucketPut.java index cc0118056df8..22fd4e6a0d44 100644 --- a/hadoop-ozone/s3gateway/src/test/java/org/apache/hadoop/ozone/s3/endpoint/TestBucketPut.java +++ b/hadoop-ozone/s3gateway/src/test/java/org/apache/hadoop/ozone/s3/endpoint/TestBucketPut.java @@ -210,6 +210,8 @@ public void testPutAclWithBothHeadersAndBody() throws Exception { && acl.getAclScope() == ACCESS) .findFirst() .orElseThrow(() -> new AssertionError("owner-id ACL not found")); + + assertEquals("owner-id", ownerAcl.getName()); } @Test From bc3552b18cc9677845259f9d826fdd031d7af88a Mon Sep 17 00:00:00 2001 From: Russole <850905junior@gmail.com> Date: Tue, 2 Dec 2025 02:13:06 +0800 Subject: [PATCH 10/16] Improve PUT ACL test coverage for header handling and precedence --- .../apache/hadoop/ozone/s3/endpoint/TestBucketPut.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/hadoop-ozone/s3gateway/src/test/java/org/apache/hadoop/ozone/s3/endpoint/TestBucketPut.java b/hadoop-ozone/s3gateway/src/test/java/org/apache/hadoop/ozone/s3/endpoint/TestBucketPut.java index 22fd4e6a0d44..22dfb84d34bf 100644 --- a/hadoop-ozone/s3gateway/src/test/java/org/apache/hadoop/ozone/s3/endpoint/TestBucketPut.java +++ b/hadoop-ozone/s3gateway/src/test/java/org/apache/hadoop/ozone/s3/endpoint/TestBucketPut.java @@ -45,6 +45,7 @@ import org.apache.hadoop.ozone.client.OzoneClient; import org.apache.hadoop.ozone.client.OzoneClientStub; import org.apache.hadoop.ozone.s3.exception.OS3Exception; +import org.apache.hadoop.ozone.security.acl.IAccessAuthorizer; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -212,6 +213,14 @@ public void testPutAclWithBothHeadersAndBody() throws Exception { .orElseThrow(() -> new AssertionError("owner-id ACL not found")); assertEquals("owner-id", ownerAcl.getName()); + + List permissions = ownerAcl.getAclList(); + + assertTrue(permissions.contains(IAccessAuthorizer.ACLType.READ), + "Expected READ permission from header"); + + assertFalse(permissions.contains(IAccessAuthorizer.ACLType.ALL), + "FULL_CONTROL/ALL from body should not be applied when header is present"); } @Test From 5257527b7a5099ac3566b882673cc233c5b0929a Mon Sep 17 00:00:00 2001 From: Russole <850905junior@gmail.com> Date: Mon, 8 Dec 2025 21:30:13 +0800 Subject: [PATCH 11/16] Refine implementation based on review comments --- .../ozone/s3/endpoint/TestBucketPut.java | 47 ++++++++++--------- 1 file changed, 25 insertions(+), 22 deletions(-) diff --git a/hadoop-ozone/s3gateway/src/test/java/org/apache/hadoop/ozone/s3/endpoint/TestBucketPut.java b/hadoop-ozone/s3gateway/src/test/java/org/apache/hadoop/ozone/s3/endpoint/TestBucketPut.java index 22dfb84d34bf..83fcfe052beb 100644 --- a/hadoop-ozone/s3gateway/src/test/java/org/apache/hadoop/ozone/s3/endpoint/TestBucketPut.java +++ b/hadoop-ozone/s3gateway/src/test/java/org/apache/hadoop/ozone/s3/endpoint/TestBucketPut.java @@ -17,8 +17,10 @@ package org.apache.hadoop.ozone.s3.endpoint; +import static java.net.HttpURLConnection.HTTP_BAD_REQUEST; import static java.net.HttpURLConnection.HTTP_CONFLICT; import static java.net.HttpURLConnection.HTTP_NOT_FOUND; +import static java.net.HttpURLConnection.HTTP_OK; import static org.apache.hadoop.ozone.OzoneAcl.AclScope.ACCESS; import static org.apache.hadoop.ozone.s3.exception.S3ErrorTable.BUCKET_ALREADY_EXISTS; import static org.apache.hadoop.ozone.s3.exception.S3ErrorTable.INVALID_ARGUMENT; @@ -46,7 +48,6 @@ import org.apache.hadoop.ozone.client.OzoneClientStub; import org.apache.hadoop.ozone.s3.exception.OS3Exception; import org.apache.hadoop.ozone.security.acl.IAccessAuthorizer; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -75,6 +76,8 @@ public class TestBucketPut { " " + " " + ""; + private static final String ACL = "acl"; + private static final String WHITESPACE_ONLY = " "; @BeforeEach public void setup() throws Exception { @@ -97,8 +100,8 @@ public void testAclWithMissingHeaders() throws Exception { InputStream body = new ByteArrayInputStream(VALID_ACL_XML.getBytes(StandardCharsets.UTF_8)); - Response resp = bucketEndpoint.put(bucketName, "acl", body); - assertEquals(200, resp.getStatus()); + Response resp = bucketEndpoint.put(bucketName, ACL, body); + assertEquals(HTTP_OK, resp.getStatus()); } @Test @@ -106,7 +109,7 @@ public void testAclWithMissingHeadersAndNoBody() throws Exception { bucketEndpoint.getClient().getObjectStore().createS3Bucket(bucketName); WebApplicationException wae = assertThrows(WebApplicationException.class, - () -> bucketEndpoint.put(bucketName, "acl", null)); + () -> bucketEndpoint.put(bucketName, ACL, null)); Throwable cause = wae.getCause(); assertNotNull(cause); @@ -115,13 +118,13 @@ public void testAclWithMissingHeadersAndNoBody() throws Exception { OS3Exception os3 = (OS3Exception) cause; assertEquals(INVALID_REQUEST.getCode(), os3.getCode()); - assertEquals(400, os3.getHttpCode()); + assertEquals(HTTP_BAD_REQUEST, os3.getHttpCode()); } @Test public void testBucketPut() throws Exception { Response response = bucketEndpoint.put(bucketName, null, null); - assertEquals(200, response.getStatus()); + assertEquals(HTTP_OK, response.getStatus()); assertNotNull(response.getLocation()); // Create-bucket on an existing bucket fails @@ -134,7 +137,7 @@ public void testBucketPut() throws Exception { @Test public void testPutAclOnNonExistingBucket() throws Exception { OS3Exception e = assertThrows(OS3Exception.class, - () -> bucketEndpoint.put(bucketName, "acl", null)); + () -> bucketEndpoint.put(bucketName, ACL, null)); assertEquals(NO_SUCH_BUCKET.getCode(), e.getCode()); assertEquals(HTTP_NOT_FOUND, e.getHttpCode()); } @@ -146,9 +149,9 @@ public void testPutAclWithGrantFullControlHeader() throws Exception { when(mockHeaders.getHeaderString(S3Acl.GRANT_FULL_CONTROL)) .thenReturn("id=\"owner-id\""); - Response resp = bucketEndpoint.put(bucketName, "acl", null); + Response resp = bucketEndpoint.put(bucketName, ACL, null); - assertEquals(200, resp.getStatus()); + assertEquals(HTTP_OK, resp.getStatus()); } @Test @@ -159,7 +162,7 @@ public void testPutAclWithInvalidXmlBody() throws Exception { "not-xml".getBytes(StandardCharsets.UTF_8)); WebApplicationException wae = assertThrows(WebApplicationException.class, - () -> bucketEndpoint.put(bucketName, "acl", body)); + () -> bucketEndpoint.put(bucketName, ACL, body)); Throwable cause = wae.getCause(); assertNotNull(cause); @@ -177,11 +180,11 @@ public void testPutAclWithMalformedGrantHeader() throws Exception { when(mockHeaders.getHeaderString(S3Acl.GRANT_FULL_CONTROL)) .thenReturn("id\"owner-id\""); - OS3Exception ex = assertThrows(OS3Exception.class, - () -> bucketEndpoint.put(bucketName, "acl", null)); + OS3Exception os3 = assertThrows(OS3Exception.class, + () -> bucketEndpoint.put(bucketName, ACL, null)); - assertEquals(INVALID_ARGUMENT.getCode(), ex.getCode()); - assertEquals(400, ex.getHttpCode()); + assertEquals(INVALID_ARGUMENT.getCode(), os3.getCode()); + assertEquals(400, os3.getHttpCode()); } @Test @@ -196,8 +199,8 @@ public void testPutAclWithBothHeadersAndBody() throws Exception { InputStream body = new ByteArrayInputStream( VALID_ACL_XML.getBytes(StandardCharsets.UTF_8)); - Response resp = bucketEndpoint.put(bucketName, "acl", body); - assertEquals(200, resp.getStatus()); + Response resp = bucketEndpoint.put(bucketName, ACL, body); + assertEquals(HTTP_OK, resp.getStatus()); OzoneBucket bucket = bucketEndpoint.getClient() .getObjectStore() @@ -230,9 +233,9 @@ public void testPutAclWithEmptyGrantHeaderValue() throws Exception { when(mockHeaders.getHeaderString(S3Acl.GRANT_FULL_CONTROL)) .thenReturn(""); // empty - Response resp = bucketEndpoint.put(bucketName, "acl", null); + Response resp = bucketEndpoint.put(bucketName, ACL, null); - Assertions.assertEquals(200, resp.getStatus()); + assertEquals(HTTP_OK, resp.getStatus()); } @Test @@ -240,12 +243,12 @@ public void testPutAclWithWhitespaceGrantHeaderValue() throws Exception { bucketEndpoint.getClient().getObjectStore().createS3Bucket(bucketName); when(mockHeaders.getHeaderString(S3Acl.GRANT_FULL_CONTROL)) - .thenReturn(" "); // whitespace only + .thenReturn(WHITESPACE_ONLY); // whitespace only OS3Exception ex = assertThrows(OS3Exception.class, - () -> bucketEndpoint.put(bucketName, "acl", null)); + () -> bucketEndpoint.put(bucketName, ACL, null)); - Assertions.assertEquals(INVALID_ARGUMENT.getCode(), ex.getCode()); - Assertions.assertEquals(400, ex.getHttpCode()); + assertEquals(INVALID_ARGUMENT.getCode(), ex.getCode()); + assertEquals(400, ex.getHttpCode()); } } From 58075a20fde3219814b26a074128dbcf173f31f6 Mon Sep 17 00:00:00 2001 From: Russole <850905junior@gmail.com> Date: Mon, 8 Dec 2025 21:34:25 +0800 Subject: [PATCH 12/16] Replace literal 400 with HTTP_BAD_REQUEST --- .../java/org/apache/hadoop/ozone/s3/endpoint/TestBucketPut.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hadoop-ozone/s3gateway/src/test/java/org/apache/hadoop/ozone/s3/endpoint/TestBucketPut.java b/hadoop-ozone/s3gateway/src/test/java/org/apache/hadoop/ozone/s3/endpoint/TestBucketPut.java index 83fcfe052beb..78d9dfd3cc3c 100644 --- a/hadoop-ozone/s3gateway/src/test/java/org/apache/hadoop/ozone/s3/endpoint/TestBucketPut.java +++ b/hadoop-ozone/s3gateway/src/test/java/org/apache/hadoop/ozone/s3/endpoint/TestBucketPut.java @@ -170,7 +170,7 @@ public void testPutAclWithInvalidXmlBody() throws Exception { OS3Exception os3 = (OS3Exception) cause; assertEquals(INVALID_REQUEST.getCode(), os3.getCode()); - assertEquals(400, os3.getHttpCode()); + assertEquals(HTTP_BAD_REQUEST, os3.getHttpCode()); } @Test From 3de3aacd9d807bcbd6773895de6c255ae167bdf8 Mon Sep 17 00:00:00 2001 From: Russole <850905junior@gmail.com> Date: Wed, 10 Dec 2025 02:26:23 +0800 Subject: [PATCH 13/16] Replace literal acl with OzoneConsts.ACL in TestBucketPut --- .../ozone/s3/endpoint/TestBucketPut.java | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/hadoop-ozone/s3gateway/src/test/java/org/apache/hadoop/ozone/s3/endpoint/TestBucketPut.java b/hadoop-ozone/s3gateway/src/test/java/org/apache/hadoop/ozone/s3/endpoint/TestBucketPut.java index 78d9dfd3cc3c..3c713f685662 100644 --- a/hadoop-ozone/s3gateway/src/test/java/org/apache/hadoop/ozone/s3/endpoint/TestBucketPut.java +++ b/hadoop-ozone/s3gateway/src/test/java/org/apache/hadoop/ozone/s3/endpoint/TestBucketPut.java @@ -76,7 +76,6 @@ public class TestBucketPut { " " + " " + ""; - private static final String ACL = "acl"; private static final String WHITESPACE_ONLY = " "; @BeforeEach @@ -100,7 +99,7 @@ public void testAclWithMissingHeaders() throws Exception { InputStream body = new ByteArrayInputStream(VALID_ACL_XML.getBytes(StandardCharsets.UTF_8)); - Response resp = bucketEndpoint.put(bucketName, ACL, body); + Response resp = bucketEndpoint.put(bucketName, OzoneConsts.ACL, body); assertEquals(HTTP_OK, resp.getStatus()); } @@ -109,7 +108,7 @@ public void testAclWithMissingHeadersAndNoBody() throws Exception { bucketEndpoint.getClient().getObjectStore().createS3Bucket(bucketName); WebApplicationException wae = assertThrows(WebApplicationException.class, - () -> bucketEndpoint.put(bucketName, ACL, null)); + () -> bucketEndpoint.put(bucketName, OzoneConsts.ACL, null)); Throwable cause = wae.getCause(); assertNotNull(cause); @@ -137,7 +136,7 @@ public void testBucketPut() throws Exception { @Test public void testPutAclOnNonExistingBucket() throws Exception { OS3Exception e = assertThrows(OS3Exception.class, - () -> bucketEndpoint.put(bucketName, ACL, null)); + () -> bucketEndpoint.put(bucketName, OzoneConsts.ACL, null)); assertEquals(NO_SUCH_BUCKET.getCode(), e.getCode()); assertEquals(HTTP_NOT_FOUND, e.getHttpCode()); } @@ -149,7 +148,7 @@ public void testPutAclWithGrantFullControlHeader() throws Exception { when(mockHeaders.getHeaderString(S3Acl.GRANT_FULL_CONTROL)) .thenReturn("id=\"owner-id\""); - Response resp = bucketEndpoint.put(bucketName, ACL, null); + Response resp = bucketEndpoint.put(bucketName, OzoneConsts.ACL, null); assertEquals(HTTP_OK, resp.getStatus()); } @@ -162,7 +161,7 @@ public void testPutAclWithInvalidXmlBody() throws Exception { "not-xml".getBytes(StandardCharsets.UTF_8)); WebApplicationException wae = assertThrows(WebApplicationException.class, - () -> bucketEndpoint.put(bucketName, ACL, body)); + () -> bucketEndpoint.put(bucketName, OzoneConsts.ACL, body)); Throwable cause = wae.getCause(); assertNotNull(cause); @@ -181,7 +180,7 @@ public void testPutAclWithMalformedGrantHeader() throws Exception { .thenReturn("id\"owner-id\""); OS3Exception os3 = assertThrows(OS3Exception.class, - () -> bucketEndpoint.put(bucketName, ACL, null)); + () -> bucketEndpoint.put(bucketName, OzoneConsts.ACL, null)); assertEquals(INVALID_ARGUMENT.getCode(), os3.getCode()); assertEquals(400, os3.getHttpCode()); @@ -199,7 +198,7 @@ public void testPutAclWithBothHeadersAndBody() throws Exception { InputStream body = new ByteArrayInputStream( VALID_ACL_XML.getBytes(StandardCharsets.UTF_8)); - Response resp = bucketEndpoint.put(bucketName, ACL, body); + Response resp = bucketEndpoint.put(bucketName, OzoneConsts.ACL, body); assertEquals(HTTP_OK, resp.getStatus()); OzoneBucket bucket = bucketEndpoint.getClient() @@ -233,7 +232,7 @@ public void testPutAclWithEmptyGrantHeaderValue() throws Exception { when(mockHeaders.getHeaderString(S3Acl.GRANT_FULL_CONTROL)) .thenReturn(""); // empty - Response resp = bucketEndpoint.put(bucketName, ACL, null); + Response resp = bucketEndpoint.put(bucketName, OzoneConsts.ACL, null); assertEquals(HTTP_OK, resp.getStatus()); } @@ -246,7 +245,7 @@ public void testPutAclWithWhitespaceGrantHeaderValue() throws Exception { .thenReturn(WHITESPACE_ONLY); // whitespace only OS3Exception ex = assertThrows(OS3Exception.class, - () -> bucketEndpoint.put(bucketName, ACL, null)); + () -> bucketEndpoint.put(bucketName, OzoneConsts.ACL, null)); assertEquals(INVALID_ARGUMENT.getCode(), ex.getCode()); assertEquals(400, ex.getHttpCode()); From c426daa1abe60268fe27da37dbdbce9a18cce363 Mon Sep 17 00:00:00 2001 From: Russole <850905junior@gmail.com> Date: Mon, 15 Dec 2025 22:42:11 +0800 Subject: [PATCH 14/16] Replace 400 with HTTP_BAD_REQUEST --- .../org/apache/hadoop/ozone/s3/endpoint/TestBucketPut.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hadoop-ozone/s3gateway/src/test/java/org/apache/hadoop/ozone/s3/endpoint/TestBucketPut.java b/hadoop-ozone/s3gateway/src/test/java/org/apache/hadoop/ozone/s3/endpoint/TestBucketPut.java index 3c713f685662..5c321f209e01 100644 --- a/hadoop-ozone/s3gateway/src/test/java/org/apache/hadoop/ozone/s3/endpoint/TestBucketPut.java +++ b/hadoop-ozone/s3gateway/src/test/java/org/apache/hadoop/ozone/s3/endpoint/TestBucketPut.java @@ -183,7 +183,7 @@ public void testPutAclWithMalformedGrantHeader() throws Exception { () -> bucketEndpoint.put(bucketName, OzoneConsts.ACL, null)); assertEquals(INVALID_ARGUMENT.getCode(), os3.getCode()); - assertEquals(400, os3.getHttpCode()); + assertEquals(HTTP_BAD_REQUEST, os3.getHttpCode()); } @Test @@ -248,6 +248,6 @@ public void testPutAclWithWhitespaceGrantHeaderValue() throws Exception { () -> bucketEndpoint.put(bucketName, OzoneConsts.ACL, null)); assertEquals(INVALID_ARGUMENT.getCode(), ex.getCode()); - assertEquals(400, ex.getHttpCode()); + assertEquals(HTTP_BAD_REQUEST, ex.getHttpCode()); } } From 89921717d4df1870786a4d8cb60704047cc9a9a6 Mon Sep 17 00:00:00 2001 From: Russole <850905junior@gmail.com> Date: Wed, 24 Dec 2025 06:17:23 +0800 Subject: [PATCH 15/16] Update Put ACL tests to align with refactored endpoint --- .../ozone/s3/endpoint/TestBucketPut.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/hadoop-ozone/s3gateway/src/test/java/org/apache/hadoop/ozone/s3/endpoint/TestBucketPut.java b/hadoop-ozone/s3gateway/src/test/java/org/apache/hadoop/ozone/s3/endpoint/TestBucketPut.java index 5674eaa9c429..d89288f6d0ba 100644 --- a/hadoop-ozone/s3gateway/src/test/java/org/apache/hadoop/ozone/s3/endpoint/TestBucketPut.java +++ b/hadoop-ozone/s3gateway/src/test/java/org/apache/hadoop/ozone/s3/endpoint/TestBucketPut.java @@ -100,7 +100,7 @@ public void testAclWithMissingHeaders() throws Exception { InputStream body = new ByteArrayInputStream(VALID_ACL_XML.getBytes(StandardCharsets.UTF_8)); - Response resp = bucketEndpoint.put(bucketName, body); + Response resp = bucketEndpoint.putAcl(bucketName, body); assertEquals(HTTP_OK, resp.getStatus()); } @@ -109,7 +109,7 @@ public void testAclWithMissingHeadersAndNoBody() throws Exception { bucketEndpoint.getClient().getObjectStore().createS3Bucket(bucketName); WebApplicationException wae = assertThrows(WebApplicationException.class, - () -> bucketEndpoint.put(bucketName, null)); + () -> bucketEndpoint.putAcl(bucketName, null)); Throwable cause = wae.getCause(); assertNotNull(cause); @@ -147,7 +147,7 @@ public void testBucketPut() throws Exception { @Test public void testPutAclOnNonExistingBucket() throws Exception { OS3Exception e = assertThrows(OS3Exception.class, - () -> bucketEndpoint.put(bucketName, null)); + () -> bucketEndpoint.putAcl(bucketName, null)); assertEquals(NO_SUCH_BUCKET.getCode(), e.getCode()); assertEquals(HTTP_NOT_FOUND, e.getHttpCode()); } @@ -159,7 +159,7 @@ public void testPutAclWithGrantFullControlHeader() throws Exception { when(mockHeaders.getHeaderString(S3Acl.GRANT_FULL_CONTROL)) .thenReturn("id=\"owner-id\""); - Response resp = bucketEndpoint.put(bucketName, null); + Response resp = bucketEndpoint.putAcl(bucketName, null); assertEquals(HTTP_OK, resp.getStatus()); } @@ -172,7 +172,7 @@ public void testPutAclWithInvalidXmlBody() throws Exception { "not-xml".getBytes(StandardCharsets.UTF_8)); WebApplicationException wae = assertThrows(WebApplicationException.class, - () -> bucketEndpoint.put(bucketName, body)); + () -> bucketEndpoint.putAcl(bucketName, body)); Throwable cause = wae.getCause(); assertNotNull(cause); @@ -191,7 +191,7 @@ public void testPutAclWithMalformedGrantHeader() throws Exception { .thenReturn("id\"owner-id\""); OS3Exception os3 = assertThrows(OS3Exception.class, - () -> bucketEndpoint.put(bucketName, null)); + () -> bucketEndpoint.putAcl(bucketName, null)); assertEquals(INVALID_ARGUMENT.getCode(), os3.getCode()); assertEquals(HTTP_BAD_REQUEST, os3.getHttpCode()); @@ -209,7 +209,7 @@ public void testPutAclWithBothHeadersAndBody() throws Exception { InputStream body = new ByteArrayInputStream( VALID_ACL_XML.getBytes(StandardCharsets.UTF_8)); - Response resp = bucketEndpoint.put(bucketName, body); + Response resp = bucketEndpoint.putAcl(bucketName, body); assertEquals(HTTP_OK, resp.getStatus()); OzoneBucket bucket = bucketEndpoint.getClient() @@ -253,7 +253,7 @@ public void testPutAclWithEmptyGrantHeaderValue() throws Exception { when(mockHeaders.getHeaderString(S3Acl.GRANT_FULL_CONTROL)) .thenReturn(""); // empty - Response resp = bucketEndpoint.put(bucketName, null); + Response resp = bucketEndpoint.putAcl(bucketName, null); assertEquals(HTTP_OK, resp.getStatus()); } @@ -266,7 +266,7 @@ public void testPutAclWithWhitespaceGrantHeaderValue() throws Exception { .thenReturn(WHITESPACE_ONLY); // whitespace only OS3Exception ex = assertThrows(OS3Exception.class, - () -> bucketEndpoint.put(bucketName, null)); + () -> bucketEndpoint.putAcl(bucketName, null)); assertEquals(INVALID_ARGUMENT.getCode(), ex.getCode()); assertEquals(HTTP_BAD_REQUEST, ex.getHttpCode()); From 331719dae595a2971a34747bdda5c04e60654d31 Mon Sep 17 00:00:00 2001 From: Russole <850905junior@gmail.com> Date: Wed, 24 Dec 2025 06:27:34 +0800 Subject: [PATCH 16/16] Fix CheckStyle --- .../java/org/apache/hadoop/ozone/s3/endpoint/TestBucketPut.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hadoop-ozone/s3gateway/src/test/java/org/apache/hadoop/ozone/s3/endpoint/TestBucketPut.java b/hadoop-ozone/s3gateway/src/test/java/org/apache/hadoop/ozone/s3/endpoint/TestBucketPut.java index d89288f6d0ba..e3e163ea0b36 100644 --- a/hadoop-ozone/s3gateway/src/test/java/org/apache/hadoop/ozone/s3/endpoint/TestBucketPut.java +++ b/hadoop-ozone/s3gateway/src/test/java/org/apache/hadoop/ozone/s3/endpoint/TestBucketPut.java @@ -23,9 +23,9 @@ import static java.net.HttpURLConnection.HTTP_OK; import static org.apache.hadoop.ozone.OzoneAcl.AclScope.ACCESS; import static org.apache.hadoop.ozone.s3.exception.S3ErrorTable.BUCKET_ALREADY_EXISTS; -import static org.apache.hadoop.ozone.s3.exception.S3ErrorTable.MALFORMED_HEADER; import static org.apache.hadoop.ozone.s3.exception.S3ErrorTable.INVALID_ARGUMENT; import static org.apache.hadoop.ozone.s3.exception.S3ErrorTable.INVALID_REQUEST; +import static org.apache.hadoop.ozone.s3.exception.S3ErrorTable.MALFORMED_HEADER; import static org.apache.hadoop.ozone.s3.exception.S3ErrorTable.NO_SUCH_BUCKET; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse;