adutra commented on code in PR #11995:
URL: https://github.com/apache/iceberg/pull/11995#discussion_r1946309127


##########
aws/src/test/java/org/apache/iceberg/aws/TestRESTSigV4AuthSession.java:
##########
@@ -0,0 +1,294 @@
+/*
+ * 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.iceberg.aws;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.when;
+
+import java.net.URI;
+import java.util.Map;
+import org.apache.iceberg.catalog.Namespace;
+import org.apache.iceberg.rest.HTTPHeaders;
+import org.apache.iceberg.rest.HTTPHeaders.HTTPHeader;
+import org.apache.iceberg.rest.HTTPRequest;
+import org.apache.iceberg.rest.HTTPRequest.HTTPMethod;
+import org.apache.iceberg.rest.ImmutableHTTPRequest;
+import org.apache.iceberg.rest.auth.AuthSession;
+import org.apache.iceberg.rest.requests.CreateNamespaceRequest;
+import org.junit.jupiter.api.Test;
+import org.mockito.Mockito;
+import software.amazon.awssdk.auth.signer.Aws4Signer;
+
+class TestRESTSigV4AuthSession {
+
+  private final Aws4Signer signer = Aws4Signer.create();
+
+  private final AwsProperties awsProperties =
+      new AwsProperties(
+          Map.of(
+              // CI environment doesn't have credentials, but a value must be 
set for signing
+              AwsProperties.REST_SIGNER_REGION,
+              "us-west-2",
+              AwsProperties.REST_ACCESS_KEY_ID,
+              "id",
+              AwsProperties.REST_SECRET_ACCESS_KEY,
+              "secret"));
+
+  @Test
+  void authenticateWithoutBody() {
+    HTTPRequest request = Mockito.mock(HTTPRequest.class);
+    AuthSession delegate = Mockito.mock(AuthSession.class);
+    when(delegate.authenticate(any()))
+        .thenReturn(
+            ImmutableHTTPRequest.builder()
+                .method(HTTPMethod.GET)
+                .baseUri(URI.create("http://localhost:8080";))
+                .path("path")
+                .headers(
+                    HTTPHeaders.of(
+                        HTTPHeader.of("Content-Type", "application/json"),
+                        HTTPHeader.of("Content-Encoding", "gzip")))
+                .build());
+    try (RESTSigV4AuthSession session = new RESTSigV4AuthSession(signer, 
delegate, awsProperties)) {

Review Comment:
   I added tests for null parameters but I don't see how to test missing props, 
because `AwsProperties` falls back to environment variables in that case.



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