From 2a3f4afd4b124c3999dd80d2423d2a9132fd0309 Mon Sep 17 00:00:00 2001 From: Alexandre Dutra Date: Thu, 19 Dec 2024 21:41:17 +0100 Subject: [PATCH] AuthManager constructor --- .../java/org/apache/iceberg/rest/auth/AuthManagers.java | 1 - .../java/org/apache/iceberg/rest/auth/BasicAuthManager.java | 4 ++++ .../java/org/apache/iceberg/rest/auth/NoopAuthManager.java | 4 ++++ .../org/apache/iceberg/rest/auth/TestBasicAuthManager.java | 6 +++--- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/core/src/main/java/org/apache/iceberg/rest/auth/AuthManagers.java b/core/src/main/java/org/apache/iceberg/rest/auth/AuthManagers.java index 948f549e02da..42c2b1eeba83 100644 --- a/core/src/main/java/org/apache/iceberg/rest/auth/AuthManagers.java +++ b/core/src/main/java/org/apache/iceberg/rest/auth/AuthManagers.java @@ -53,7 +53,6 @@ public static AuthManager loadAuthManager(String name, Map prope DynConstructors.builder(AuthManager.class) .loader(AuthManagers.class.getClassLoader()) .impl(impl, String.class) // with name - .impl(impl) // without name .buildChecked(); } catch (NoSuchMethodException e) { throw new IllegalArgumentException( diff --git a/core/src/main/java/org/apache/iceberg/rest/auth/BasicAuthManager.java b/core/src/main/java/org/apache/iceberg/rest/auth/BasicAuthManager.java index d19fc7302885..d0d56d3d3794 100644 --- a/core/src/main/java/org/apache/iceberg/rest/auth/BasicAuthManager.java +++ b/core/src/main/java/org/apache/iceberg/rest/auth/BasicAuthManager.java @@ -26,6 +26,10 @@ /** An auth manager that adds static BASIC authentication data to outgoing HTTP requests. */ public final class BasicAuthManager implements AuthManager { + public BasicAuthManager(String ignored) { + // no-op + } + @Override public AuthSession catalogSession(RESTClient sharedClient, Map properties) { Preconditions.checkArgument( diff --git a/core/src/main/java/org/apache/iceberg/rest/auth/NoopAuthManager.java b/core/src/main/java/org/apache/iceberg/rest/auth/NoopAuthManager.java index 0dc617ecc12c..d706d78ef3ae 100644 --- a/core/src/main/java/org/apache/iceberg/rest/auth/NoopAuthManager.java +++ b/core/src/main/java/org/apache/iceberg/rest/auth/NoopAuthManager.java @@ -24,6 +24,10 @@ /** An auth manager that does not add any authentication data to outgoing HTTP requests. */ public class NoopAuthManager implements AuthManager { + public NoopAuthManager(String ignored) { + // no-op + } + @Override public AuthSession catalogSession(RESTClient sharedClient, Map properties) { return AuthSession.EMPTY; diff --git a/core/src/test/java/org/apache/iceberg/rest/auth/TestBasicAuthManager.java b/core/src/test/java/org/apache/iceberg/rest/auth/TestBasicAuthManager.java index 6c4de441ae2a..c34654cdeff5 100644 --- a/core/src/test/java/org/apache/iceberg/rest/auth/TestBasicAuthManager.java +++ b/core/src/test/java/org/apache/iceberg/rest/auth/TestBasicAuthManager.java @@ -29,7 +29,7 @@ class TestBasicAuthManager { @Test void missingUsername() { - try (AuthManager authManager = new BasicAuthManager()) { + try (AuthManager authManager = new BasicAuthManager("test")) { assertThatThrownBy(() -> authManager.catalogSession(null, Map.of())) .isInstanceOf(IllegalArgumentException.class) .hasMessage( @@ -39,7 +39,7 @@ void missingUsername() { @Test void missingPassword() { - try (AuthManager authManager = new BasicAuthManager()) { + try (AuthManager authManager = new BasicAuthManager("test")) { Map properties = Map.of(AuthProperties.BASIC_USERNAME, "alice"); assertThatThrownBy(() -> authManager.catalogSession(null, properties)) .isInstanceOf(IllegalArgumentException.class) @@ -52,7 +52,7 @@ void missingPassword() { void success() { Map properties = Map.of(AuthProperties.BASIC_USERNAME, "alice", AuthProperties.BASIC_PASSWORD, "secret"); - try (AuthManager authManager = new BasicAuthManager(); + try (AuthManager authManager = new BasicAuthManager("test"); AuthSession session = authManager.catalogSession(null, properties)) { assertThat(session) .isEqualTo(