len548 commented on code in PR #8794:
URL: https://github.com/apache/ozone/pull/8794#discussion_r2285781883


##########
hadoop-ozone/s3gateway/src/test/java/org/apache/hadoop/ozone/s3web/s3sts/TestSTS.java:
##########
@@ -0,0 +1,109 @@
+/*
+ * 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.s3web.s3sts;
+
+import static org.apache.hadoop.ozone.OzoneConfigKeys.OZONE_S3_ADMINISTRATORS;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import javax.ws.rs.container.ContainerRequestContext;
+import javax.ws.rs.core.HttpHeaders;
+import javax.ws.rs.core.Response;
+import org.apache.hadoop.hdds.conf.OzoneConfiguration;
+import org.apache.hadoop.ozone.client.OzoneClient;
+import org.apache.hadoop.ozone.client.OzoneClientStub;
+import org.apache.hadoop.ozone.s3.OzoneConfigurationHolder;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.mockito.Mock;
+
+/**
+ * Test for S3 STS endpoint.
+ */
+public class TestSTS {
+  private OzoneClient clientStub;
+  private S3STSEndpoint endpoint;
+  private HttpHeaders httpHeaders;
+
+  @Mock
+  private ContainerRequestContext context;
+
+  @BeforeEach
+  public void setup() throws Exception {
+    OzoneConfiguration config = new OzoneConfiguration();
+    config.set(OZONE_S3_ADMINISTRATORS, "test-user");
+    OzoneConfigurationHolder.setConfiguration(config);
+    clientStub = new OzoneClientStub();
+    httpHeaders = mock(HttpHeaders.class);
+    when(httpHeaders.getHeaderString("Authorization"))
+        .thenReturn("AWS4-HMAC-SHA256 
Credential=test-user/20240709/us-east-1/s3/aws4_request, "
+            + "SignedHeaders=host;x-amz-date, Signature=some-signature");
+    endpoint = new S3STSEndpoint();

Review Comment:
   STS service is similar to 
[`s3secret`](https://github.com/apache/ozone/tree/435fe7e241f7f5072fe3f411ddaf2daa9d4283a8/hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3secret).
 Both services provide AWS credentials. So it was a intuitively natural idea to 
follow how `s3secret` is designed. So the idea of using the `S3STSEndpointBase` 
comes from 
[`S3SecretEndpointBase`](https://github.com/apache/ozone/blob/435fe7e241f7f5072fe3f411ddaf2daa9d4283a8/hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3secret/S3SecretEndpointBase.java)
 in `s3secret`. They are identical classes with different names in this PR but 
the next PR is supposed to add some utility methods to `S3STSEndpointBase`. 
These are necessary for operations of `S3STSEndpoint`. Also `EndpointBase` is 
not suitable for credential management endpoint like STS and S3Secret because 
it is to provide utility methods for s3 content operation endpoints such as 
`BucketEndpoint`. I hope it answers your question.
  Thank you for asking :)



-- 
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: issues-unsubscr...@ozone.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@ozone.apache.org
For additional commands, e-mail: issues-h...@ozone.apache.org

Reply via email to