You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by "snazy (via GitHub)" <gi...@apache.org> on 2023/11/14 09:42:35 UTC

[PR] GCS: Allow no-auth for testing purposes [iceberg]

snazy opened a new pull request, #9061:
URL: https://github.com/apache/iceberg/pull/9061

   Although there is no "official" Google Cloud Storage emulator available yet, there is [one available](https://github.com/oittaa/gcp-storage-emulator) that allows at least some basic testing. To use an emulator, the client needs to be configured to use no authentication, otherwise it will fallback to "automatic credential detection".


-- 
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-unsubscribe@iceberg.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] GCS: Allow no-auth for testing purposes [iceberg]

Posted by "nastra (via GitHub)" <gi...@apache.org>.
nastra commented on code in PR #9061:
URL: https://github.com/apache/iceberg/pull/9061#discussion_r1392604814


##########
gcp/src/main/java/org/apache/iceberg/gcp/GCPProperties.java:
##########
@@ -18,13 +18,15 @@
  */
 package org.apache.iceberg.gcp;
 
+import com.google.api.client.util.Preconditions;
 import java.io.Serializable;
 import java.util.Date;
 import java.util.Map;
 import java.util.Optional;
 import org.apache.iceberg.util.PropertyUtil;
 
 public class GCPProperties implements Serializable {
+

Review Comment:
   unnecessary change



-- 
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-unsubscribe@iceberg.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] GCS: Allow no-auth for testing purposes [iceberg]

Posted by "nastra (via GitHub)" <gi...@apache.org>.
nastra commented on PR #9061:
URL: https://github.com/apache/iceberg/pull/9061#issuecomment-1811980461

   @bryanck could you review this one please?


-- 
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-unsubscribe@iceberg.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] GCS: Allow no-auth for testing purposes [iceberg]

Posted by "nastra (via GitHub)" <gi...@apache.org>.
nastra commented on code in PR #9061:
URL: https://github.com/apache/iceberg/pull/9061#discussion_r1393802050


##########
gcp/src/test/java/org/apache/iceberg/gcp/GCPPropertiesTest.java:
##########
@@ -0,0 +1,48 @@
+/*
+ * 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.gcp;
+
+import static org.apache.iceberg.gcp.GCPProperties.GCS_NO_AUTH;
+import static org.apache.iceberg.gcp.GCPProperties.GCS_OAUTH2_TOKEN;
+
+import org.apache.iceberg.relocated.com.google.common.collect.ImmutableMap;
+import org.assertj.core.api.Assertions;
+import org.junit.jupiter.api.Test;
+
+public class GCPPropertiesTest {
+
+  @Test
+  public void testOAuthWithNoAuth() {
+    Assertions.assertThatIllegalStateException()
+        .isThrownBy(
+            () ->
+                new GCPProperties(ImmutableMap.of(GCS_OAUTH2_TOKEN, "oauth", GCS_NO_AUTH, "true")))
+        .withMessage(
+            String.format(
+                "Invalid auth settings: must not configure %s and %s",
+                GCS_NO_AUTH, GCS_OAUTH2_TOKEN));
+    Assertions.assertThatNoException()

Review Comment:
   rather than just checking that no exception has been thrown, I think the better alternative would be:
   
   ```
       GCPProperties gcpProperties =
           new GCPProperties(ImmutableMap.of(GCS_OAUTH2_TOKEN, "oauth", GCS_NO_AUTH, "false"));
       assertThat(gcpProperties.noAuth()).isFalse();
       assertThat(gcpProperties.oauth2Token()).isPresent().get().isEqualTo("oauth");
   
       gcpProperties = new GCPProperties(ImmutableMap.of(GCS_NO_AUTH, "true"));
       assertThat(gcpProperties.noAuth()).isTrue();
       assertThat(gcpProperties.oauth2Token()).isNotPresent();
   ```



-- 
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-unsubscribe@iceberg.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] GCS: Allow no-auth for testing purposes [iceberg]

Posted by "nastra (via GitHub)" <gi...@apache.org>.
nastra commented on code in PR #9061:
URL: https://github.com/apache/iceberg/pull/9061#discussion_r1392616478


##########
gcp/src/main/java/org/apache/iceberg/gcp/GCPProperties.java:
##########
@@ -90,6 +95,10 @@ public GCPProperties(Map<String, String> properties) {
       gcsOAuth2TokenExpiresAt =
           new Date(Long.parseLong(properties.get(GCS_OAUTH2_TOKEN_EXPIRES_AT)));
     }
+    gcsNoAuth = Boolean.parseBoolean(properties.getOrDefault(GCS_NO_AUTH, "false"));
+    Preconditions.checkState(

Review Comment:
   it would be good to also have a test that specifically checks that you can only set one of these



-- 
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-unsubscribe@iceberg.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] GCS: Allow no-auth for testing purposes [iceberg]

Posted by "snazy (via GitHub)" <gi...@apache.org>.
snazy commented on code in PR #9061:
URL: https://github.com/apache/iceberg/pull/9061#discussion_r1394092708


##########
gcp/src/main/java/org/apache/iceberg/gcp/GCPProperties.java:
##########
@@ -18,13 +18,15 @@
  */
 package org.apache.iceberg.gcp;
 
+import com.google.api.client.util.Preconditions;
 import java.io.Serializable;
 import java.util.Date;
 import java.util.Map;
 import java.util.Optional;
 import org.apache.iceberg.util.PropertyUtil;
 
 public class GCPProperties implements Serializable {
+

Review Comment:
   Nope - it's spottless that re-adds it everytime



-- 
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-unsubscribe@iceberg.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] GCS: Allow no-auth for testing purposes [iceberg]

Posted by "nastra (via GitHub)" <gi...@apache.org>.
nastra commented on code in PR #9061:
URL: https://github.com/apache/iceberg/pull/9061#discussion_r1392605260


##########
gcp/src/main/java/org/apache/iceberg/gcp/GCPProperties.java:
##########
@@ -18,13 +18,15 @@
  */
 package org.apache.iceberg.gcp;
 
+import com.google.api.client.util.Preconditions;

Review Comment:
   yes, this is a wrong import and should use the one from `iceberg-guava`



-- 
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-unsubscribe@iceberg.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] GCS: Allow no-auth for testing purposes [iceberg]

Posted by "XN137 (via GitHub)" <gi...@apache.org>.
XN137 commented on code in PR #9061:
URL: https://github.com/apache/iceberg/pull/9061#discussion_r1392354434


##########
gcp/src/main/java/org/apache/iceberg/gcp/GCPProperties.java:
##########
@@ -18,13 +18,15 @@
  */
 package org.apache.iceberg.gcp;
 
+import com.google.api.client.util.Preconditions;

Review Comment:
   wrong import?



-- 
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-unsubscribe@iceberg.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] GCS: Allow no-auth for testing purposes [iceberg]

Posted by "nastra (via GitHub)" <gi...@apache.org>.
nastra commented on code in PR #9061:
URL: https://github.com/apache/iceberg/pull/9061#discussion_r1394330718


##########
gcp/src/main/java/org/apache/iceberg/gcp/GCPProperties.java:
##########
@@ -18,13 +18,15 @@
  */
 package org.apache.iceberg.gcp;
 
+import com.google.api.client.util.Preconditions;
 import java.io.Serializable;
 import java.util.Date;
 import java.util.Map;
 import java.util.Optional;
 import org.apache.iceberg.util.PropertyUtil;
 
 public class GCPProperties implements Serializable {
+

Review Comment:
   that's weird, it doesn't do that for me. Also the build would have failed if that code here wouldn't be spotless-compliant



-- 
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-unsubscribe@iceberg.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] GCS: Allow no-auth for testing purposes [iceberg]

Posted by "nastra (via GitHub)" <gi...@apache.org>.
nastra merged PR #9061:
URL: https://github.com/apache/iceberg/pull/9061


-- 
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-unsubscribe@iceberg.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] GCS: Allow no-auth for testing purposes [iceberg]

Posted by "nastra (via GitHub)" <gi...@apache.org>.
nastra commented on code in PR #9061:
URL: https://github.com/apache/iceberg/pull/9061#discussion_r1395925805


##########
gcp/src/main/java/org/apache/iceberg/gcp/GCPProperties.java:
##########
@@ -18,13 +18,15 @@
  */
 package org.apache.iceberg.gcp;
 
+import com.google.api.client.util.Preconditions;
 import java.io.Serializable;
 import java.util.Date;
 import java.util.Map;
 import java.util.Optional;
 import org.apache.iceberg.util.PropertyUtil;
 
 public class GCPProperties implements Serializable {
+

Review Comment:
   PR is ready to go once this diff is reverted



-- 
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-unsubscribe@iceberg.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] GCS: Allow no-auth for testing purposes [iceberg]

Posted by "nastra (via GitHub)" <gi...@apache.org>.
nastra commented on code in PR #9061:
URL: https://github.com/apache/iceberg/pull/9061#discussion_r1392604572


##########
gcp/src/main/java/org/apache/iceberg/gcp/gcs/GCSFileIO.java:
##########
@@ -55,6 +56,7 @@
  * Overview</a>
  */
 public class GCSFileIO implements DelegateFileIO {
+

Review Comment:
   unnecessary change



-- 
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-unsubscribe@iceberg.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] GCS: Allow no-auth for testing purposes [iceberg]

Posted by "nastra (via GitHub)" <gi...@apache.org>.
nastra commented on code in PR #9061:
URL: https://github.com/apache/iceberg/pull/9061#discussion_r1392613903


##########
gcp/src/main/java/org/apache/iceberg/gcp/GCPProperties.java:
##########
@@ -90,6 +95,10 @@ public GCPProperties(Map<String, String> properties) {
       gcsOAuth2TokenExpiresAt =
           new Date(Long.parseLong(properties.get(GCS_OAUTH2_TOKEN_EXPIRES_AT)));
     }
+    gcsNoAuth = Boolean.parseBoolean(properties.getOrDefault(GCS_NO_AUTH, "false"));
+    Preconditions.checkState(
+        !(gcsOAuth2Token != null && gcsNoAuth),
+        "Must not configure " + GCS_NO_AUTH + " and " + GCS_OAUTH2_TOKEN);

Review Comment:
   ```suggestion
           "Invalid auth settings: must not configure %s and %s", GCS_NO_AUTH, GCS_OAUTH2_TOKEN);
   ```



-- 
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-unsubscribe@iceberg.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] GCS: Allow no-auth for testing purposes [iceberg]

Posted by "nastra (via GitHub)" <gi...@apache.org>.
nastra commented on code in PR #9061:
URL: https://github.com/apache/iceberg/pull/9061#discussion_r1393802495


##########
gcp/src/main/java/org/apache/iceberg/gcp/GCPProperties.java:
##########
@@ -18,13 +18,15 @@
  */
 package org.apache.iceberg.gcp;
 
+import com.google.api.client.util.Preconditions;
 import java.io.Serializable;
 import java.util.Date;
 import java.util.Map;
 import java.util.Optional;
 import org.apache.iceberg.util.PropertyUtil;
 
 public class GCPProperties implements Serializable {
+

Review Comment:
   @snazy can you please remove that newline change?



-- 
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-unsubscribe@iceberg.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] GCS: Allow no-auth for testing purposes [iceberg]

Posted by "bryanck (via GitHub)" <gi...@apache.org>.
bryanck commented on PR #9061:
URL: https://github.com/apache/iceberg/pull/9061#issuecomment-1814645914

   This looks good to me, as long as the format checks are passing.


-- 
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-unsubscribe@iceberg.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org