chihsuan commented on code in PR #11479:
URL: https://github.com/apache/ozone/pull/11479#discussion_r4334708135


##########
hadoop-ozone/s3gateway/src/test/java/org/apache/hadoop/ozone/s3/endpoint/TestPermissionCheck.java:
##########
@@ -103,6 +103,8 @@ public void setup() {
     S3GatewayMetrics.create(conf);
     when(client.getProxy()).thenReturn(clientProtocol);
     when(objectStore.getClientProxy()).thenReturn(clientProtocol);
+    when(clientProtocol.getS3BucketDetails(anyString())).thenReturn(bucket);

Review Comment:
   nit: Could we drop the `volume.getBucket(...)` stubs below too? They're no 
longer hit.



##########
hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/TestOMMetadataReader.java:
##########
@@ -1045,4 +1057,77 @@ public void 
getKeyInfoServesObjectStoreLayoutWhenNotRequested(boolean assumeS3Co
 
     verify(keyManager).getKeyInfo(any(OmKeyArgs.class), 
any(ResolvedBucket.class), any());
   }
+
+  @Test
+  public void getBucketInfoResolvesS3VolumeWhenAssumeS3Context() throws 
Exception {
+    BucketManager bucketManager = mock(BucketManager.class);
+    OmMetadataReader reader = mock(OmMetadataReader.class);
+    OMMetrics metrics = mock(OMMetrics.class);
+    OzoneManager ozoneManager = newBucketInfoOzoneManager(bucketManager, 
reader, metrics);
+    OmBucketInfo bucket = bucketInfo(TENANT_VOLUME_NAME);
+    when(bucketManager.getBucketInfo(TENANT_VOLUME_NAME, 
BUCKET_NAME)).thenReturn(bucket);
+
+    BucketInfoWithVolumeContext result = 
ozoneManager.getBucketInfo(VOLUME_NAME, BUCKET_NAME, true);
+
+    assertSame(bucket, result.getBucketInfo());
+    assertEquals(Optional.of("user"), result.getUserPrincipal());
+    verify(ozoneManager).getS3VolumeContext(true);
+    verify(reader).checkAcls(BUCKET, OZONE, READ, TENANT_VOLUME_NAME, 
BUCKET_NAME, null);
+    verify(metrics).incNumBucketInfos();
+  }
+
+  @Test
+  public void getBucketInfoUsesRequestedVolumeWithoutAssumeS3Context() throws 
Exception {
+    BucketManager bucketManager = mock(BucketManager.class);
+    OmMetadataReader reader = mock(OmMetadataReader.class);
+    OzoneManager ozoneManager = newBucketInfoOzoneManager(bucketManager, 
reader, mock(OMMetrics.class));
+    OmBucketInfo bucket = bucketInfo(VOLUME_NAME);
+    when(bucketManager.getBucketInfo(VOLUME_NAME, 
BUCKET_NAME)).thenReturn(bucket);
+
+    BucketInfoWithVolumeContext result = 
ozoneManager.getBucketInfo(VOLUME_NAME, BUCKET_NAME, false);
+
+    assertSame(bucket, result.getBucketInfo());
+    assertFalse(result.getUserPrincipal().isPresent());
+    verify(ozoneManager, never()).getS3VolumeContext(anyBoolean());
+    verify(reader).checkAcls(BUCKET, OZONE, READ, VOLUME_NAME, BUCKET_NAME, 
null);
+  }
+
+  @Test
+  public void getBucketInfoReturnsBucketNotFoundWithoutVolumeCheck() throws 
Exception {

Review Comment:
   nit: Could we drop this test? It only asserts what its own mock throws.



##########
hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/helpers/BucketInfoWithVolumeContext.java:
##########
@@ -0,0 +1,76 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.ozone.om.helpers;
+
+import java.io.IOException;
+import java.util.Optional;
+import 
org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OMResponse;
+
+/**
+ * Wrapper class to return BucketInfo and optionally the S3 user principal.
+ */
+public final class BucketInfoWithVolumeContext {

Review Comment:
   nit: Since it no longer holds volume args, maybe `BucketInfoWithS3Context` 
fits better?



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