-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GCS: Allow no-auth for testing purposes (#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".
- Loading branch information
Showing
3 changed files
with
73 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
gcp/src/test/java/org/apache/iceberg/gcp/GCPPropertiesTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
* 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 static org.assertj.core.api.Assertions.assertThat; | ||
|
||
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)); | ||
|
||
GCPProperties gcpProperties = | ||
new GCPProperties(ImmutableMap.of(GCS_OAUTH2_TOKEN, "oauth", GCS_NO_AUTH, "false")); | ||
assertThat(gcpProperties.noAuth()).isFalse(); | ||
assertThat(gcpProperties.oauth2Token()).get().isEqualTo("oauth"); | ||
gcpProperties = new GCPProperties(ImmutableMap.of(GCS_NO_AUTH, "true")); | ||
assertThat(gcpProperties.noAuth()).isTrue(); | ||
assertThat(gcpProperties.oauth2Token()).isNotPresent(); | ||
} | ||
} |