You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iceberg.apache.org by dw...@apache.org on 2026/08/20 20:11:47 UTC
(iceberg) branch main updated: AWS, Core: Implement RemoteSigningConfig (#17709)
This is an automated email from the ASF dual-hosted git repository.
danielcweeks pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/iceberg.git
The following commit(s) were added to refs/heads/main by this push:
new 5fbbd68c80 AWS, Core: Implement RemoteSigningConfig (#17709)
5fbbd68c80 is described below
commit 5fbbd68c80aa023aa5125d545c0f94641435dfcb
Author: Alexandre Dutra <ad...@apache.org>
AuthorDate: Thu Aug 20 22:11:39 2026 +0200
AWS, Core: Implement RemoteSigningConfig (#17709)
* Core, REST, AWS: Implement RemoteSigningConfig
---
.../iceberg/aws/s3/signer/TestS3RestSigner.java | 5 +-
.../aws/s3/signer/S3V4RestSignerClient.java | 89 ++++++-------
.../apache/iceberg/aws/TestS3FileIOProperties.java | 40 +++++-
.../iceberg/aws/s3/TestS3FileIOProperties.java | 5 +-
.../aws/s3/signer/TestS3V4RestSignerClient.java | 55 ++++----
.../apache/iceberg/rest/RESTCatalogProperties.java | 31 ++++-
.../apache/iceberg/rest/RESTSessionCatalog.java | 69 ++++++++--
.../apache/iceberg/rest/RemoteSigningConfig.java | 47 +++++++
.../iceberg/rest/RemoteSigningConfigParser.java | 84 ++++++++++++
.../iceberg/rest/responses/LoadTableResponse.java | 19 ++-
.../rest/responses/LoadTableResponseParser.java | 12 ++
.../org/apache/iceberg/rest/TestRESTCatalog.java | 51 ++++++++
.../rest/TestRemoteSigningConfigParser.java | 141 +++++++++++++++++++++
.../responses/TestLoadTableResponseParser.java | 79 ++++++++++++
14 files changed, 619 insertions(+), 108 deletions(-)
diff --git a/aws/src/integration/java/org/apache/iceberg/aws/s3/signer/TestS3RestSigner.java b/aws/src/integration/java/org/apache/iceberg/aws/s3/signer/TestS3RestSigner.java
index 4e5ed3d918..6d60fba059 100644
--- a/aws/src/integration/java/org/apache/iceberg/aws/s3/signer/TestS3RestSigner.java
+++ b/aws/src/integration/java/org/apache/iceberg/aws/s3/signer/TestS3RestSigner.java
@@ -32,6 +32,7 @@ import java.util.Map;
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.stream.Collectors;
import javax.annotation.Nonnull;
+import org.apache.iceberg.CatalogProperties;
import org.apache.iceberg.aws.s3.MinioUtil;
import org.apache.iceberg.relocated.com.google.common.collect.ImmutableMap;
import org.apache.iceberg.rest.RESTCatalogProperties;
@@ -108,9 +109,9 @@ public class TestS3RestSigner {
ImmutableS3V4RestSignerClient.builder()
.properties(
ImmutableMap.of(
- RESTCatalogProperties.SIGNER_URI,
+ CatalogProperties.URI,
httpServer.getURI().toString(),
- RESTCatalogProperties.SIGNER_ENDPOINT,
+ RESTCatalogProperties.REMOTE_SIGNING_ENDPOINT,
S3SignerServlet.S3_SIGNER_ENDPOINT,
OAuth2Properties.CREDENTIAL,
"catalog:12345"))
diff --git a/aws/src/main/java/org/apache/iceberg/aws/s3/signer/S3V4RestSignerClient.java b/aws/src/main/java/org/apache/iceberg/aws/s3/signer/S3V4RestSignerClient.java
index 7a463abd3d..4d0bbc9657 100644
--- a/aws/src/main/java/org/apache/iceberg/aws/s3/signer/S3V4RestSignerClient.java
+++ b/aws/src/main/java/org/apache/iceberg/aws/s3/signer/S3V4RestSignerClient.java
@@ -23,7 +23,6 @@ import com.github.benmanes.caffeine.cache.Caffeine;
import java.io.IOException;
import java.io.InputStream;
import java.net.URI;
-import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
@@ -40,6 +39,8 @@ import org.apache.iceberg.rest.HTTPClient;
import org.apache.iceberg.rest.RESTCatalogProperties;
import org.apache.iceberg.rest.RESTClient;
import org.apache.iceberg.rest.RESTUtil;
+import org.apache.iceberg.rest.RemoteSigningConfig;
+import org.apache.iceberg.rest.RemoteSigningConfigParser;
import org.apache.iceberg.rest.ResourcePaths;
import org.apache.iceberg.rest.auth.AuthManager;
import org.apache.iceberg.rest.auth.AuthManagers;
@@ -71,23 +72,6 @@ public abstract class S3V4RestSignerClient
public static final String S3_PROVIDER = "s3";
- /**
- * @deprecated since 1.11.0, will be removed in 1.12.0; use {@link
- * RESTCatalogProperties#SIGNER_URI} instead.
- */
- @Deprecated public static final String S3_SIGNER_URI = "s3.signer.uri";
-
- /**
- * @deprecated since 1.11.0, will be removed in 1.12.0; use {@link
- * RESTCatalogProperties#SIGNER_URI} instead.
- */
- @Deprecated public static final String S3_SIGNER_ENDPOINT = "s3.signer.endpoint";
-
- /**
- * @deprecated since 1.11.0, will be removed in 1.12.0; there is no replacement.
- */
- @Deprecated static final String S3_SIGNER_DEFAULT_ENDPOINT = "v1/aws/s3/sign";
-
@VisibleForTesting static final String UNSIGNED_PAYLOAD = "UNSIGNED-PAYLOAD";
private static final String CACHE_CONTROL = "Cache-Control";
@@ -108,33 +92,30 @@ public abstract class S3V4RestSignerClient
public abstract Map<String, String> properties();
+ @Value.Derived
+ public RemoteSigningConfig remoteSigningConfig() {
+ String json = properties().get(RESTCatalogProperties.REMOTE_SIGNING_CONFIG);
+ return json == null ? RemoteSigningConfig.EMPTY : RemoteSigningConfigParser.fromJson(json);
+ }
+
@Value.Default
public Supplier<Map<String, String>> requestPropertiesSupplier() {
- return Collections::emptyMap;
+ return remoteSigningConfig()::properties;
}
@Value.Lazy
public String baseSignerUri() {
- // TODO remove in 1.12.0
- if (properties().containsKey(S3_SIGNER_URI)) {
- return properties().get(S3_SIGNER_URI);
- }
-
return properties()
.getOrDefault(RESTCatalogProperties.SIGNER_URI, properties().get(CatalogProperties.URI));
}
@Value.Lazy
public String endpoint() {
- // TODO remove in 1.12.0
- String endpointPath;
- if (properties().containsKey(S3_SIGNER_ENDPOINT)) {
- endpointPath = properties().get(S3_SIGNER_ENDPOINT);
- } else {
- endpointPath =
- properties()
- .getOrDefault(RESTCatalogProperties.SIGNER_ENDPOINT, S3_SIGNER_DEFAULT_ENDPOINT);
- }
+ String endpointPath =
+ properties()
+ .getOrDefault(
+ RESTCatalogProperties.SIGNER_ENDPOINT,
+ properties().get(RESTCatalogProperties.REMOTE_SIGNING_ENDPOINT));
return RESTUtil.resolveEndpoint(baseSignerUri(), endpointPath);
}
@@ -175,6 +156,18 @@ public abstract class S3V4RestSignerClient
OAuth2Properties.TOKEN_REFRESH_ENABLED_DEFAULT);
}
+ /**
+ * Converts the catalog-provided static {@link RemoteSigningConfig#headers() headers} into headers
+ * for the request to the signing endpoint. Multivalued headers are joined using the standard HTTP
+ * comma separator.
+ */
+ @Value.Lazy
+ Map<String, String> signingEndpointHeaders() {
+ return remoteSigningConfig().headers().entrySet().stream()
+ .map(e -> Map.entry(e.getKey(), String.join(", ", e.getValue())))
+ .collect(ImmutableMap.toImmutableMap(Map.Entry::getKey, Map.Entry::getValue));
+ }
+
private AuthManager authManager() {
if (null == authManager) {
synchronized (S3V4RestSignerClient.class) {
@@ -232,36 +225,28 @@ public abstract class S3V4RestSignerClient
@Value.Check
protected void check() {
Preconditions.checkArgument(
- properties().containsKey(S3_SIGNER_URI)
- || properties().containsKey(RESTCatalogProperties.SIGNER_URI)
+ properties().containsKey(RESTCatalogProperties.SIGNER_ENDPOINT)
+ || properties().containsKey(RESTCatalogProperties.REMOTE_SIGNING_ENDPOINT),
+ "Remote signing endpoint is required");
+
+ Preconditions.checkArgument(
+ properties().containsKey(RESTCatalogProperties.SIGNER_URI)
|| properties().containsKey(CatalogProperties.URI),
"S3 signer service URI is required");
- if (properties().containsKey(S3_SIGNER_URI)
- && !properties().containsKey(RESTCatalogProperties.SIGNER_URI)) {
+ if (properties().containsKey(RESTCatalogProperties.SIGNER_URI)) {
LOG.warn(
"S3 signer URI is configured via deprecated property {}, this won't be supported in future releases. "
- + "Please use {} instead.",
- S3_SIGNER_URI,
+ + "Please remove this property to let the signer use the default URI instead.",
RESTCatalogProperties.SIGNER_URI);
}
- if (properties().containsKey(S3_SIGNER_ENDPOINT)
- && !properties().containsKey(RESTCatalogProperties.SIGNER_ENDPOINT)) {
+ if (properties().containsKey(RESTCatalogProperties.SIGNER_ENDPOINT)) {
LOG.warn(
"Signer endpoint is configured via deprecated property {}, this won't be supported in future releases. "
- + "Please use {} instead.",
- S3_SIGNER_ENDPOINT,
+ + "Please remove this property to let the signer use the default endpoint instead.",
RESTCatalogProperties.SIGNER_ENDPOINT);
}
-
- // TODO change to required in 1.12.0
- if (!properties().containsKey(S3_SIGNER_ENDPOINT)
- && !properties().containsKey(RESTCatalogProperties.SIGNER_ENDPOINT)) {
- LOG.warn(
- "Signer endpoint is not set, this won't be supported in future releases. Using deprecated default: {}",
- S3_SIGNER_DEFAULT_ENDPOINT);
- }
}
@Override
@@ -331,7 +316,7 @@ public abstract class S3V4RestSignerClient
endpoint(),
remoteSigningRequest,
RemoteSignResponse.class,
- Map.of(),
+ signingEndpointHeaders(),
ErrorHandlers.defaultErrorHandler(),
responseHeadersConsumer);
diff --git a/aws/src/test/java/org/apache/iceberg/aws/TestS3FileIOProperties.java b/aws/src/test/java/org/apache/iceberg/aws/TestS3FileIOProperties.java
index f374a18c04..61e35f3397 100644
--- a/aws/src/test/java/org/apache/iceberg/aws/TestS3FileIOProperties.java
+++ b/aws/src/test/java/org/apache/iceberg/aws/TestS3FileIOProperties.java
@@ -28,6 +28,7 @@ import org.apache.iceberg.aws.s3.S3FileIOProperties;
import org.apache.iceberg.aws.s3.signer.S3V4RestSignerClient;
import org.apache.iceberg.relocated.com.google.common.collect.ImmutableMap;
import org.apache.iceberg.relocated.com.google.common.collect.Maps;
+import org.apache.iceberg.rest.RESTCatalogProperties;
import org.junit.jupiter.api.Test;
import org.mockito.ArgumentCaptor;
import org.mockito.Mockito;
@@ -212,7 +213,11 @@ public class TestS3FileIOProperties {
@Test
public void testS3RemoteSignerWithoutUri() {
Map<String, String> properties =
- ImmutableMap.of(S3FileIOProperties.REMOTE_SIGNING_ENABLED, "true");
+ ImmutableMap.of(
+ S3FileIOProperties.REMOTE_SIGNING_ENABLED,
+ "true",
+ RESTCatalogProperties.REMOTE_SIGNING_ENDPOINT,
+ "v1/namespaces/ns1/tables/t1/sign");
S3FileIOProperties s3Properties = new S3FileIOProperties(properties);
assertThatThrownBy(() -> s3Properties.applySignerConfiguration(S3Client.builder()))
@@ -220,12 +225,33 @@ public class TestS3FileIOProperties {
.hasMessage("S3 signer service URI is required");
}
+ @Test
+ public void testS3RemoteSignerWithoutEndpoint() {
+ Map<String, String> properties =
+ ImmutableMap.of(
+ S3FileIOProperties.REMOTE_SIGNING_ENABLED,
+ "true",
+ CatalogProperties.URI,
+ "http://localhost:12345");
+ S3FileIOProperties s3Properties = new S3FileIOProperties(properties);
+
+ assertThatThrownBy(() -> s3Properties.applySignerConfiguration(S3Client.builder()))
+ .isInstanceOf(IllegalArgumentException.class)
+ .hasMessage("Remote signing endpoint is required");
+ }
+
@Test
public void testS3RemoteSigningEnabled() {
- String uri = "http://localhost:12345";
+ String uri = "http://localhost:12345/";
+ String endpoint = "v1/namespaces/ns1/tables/t1/sign";
Map<String, String> properties =
ImmutableMap.of(
- S3FileIOProperties.REMOTE_SIGNING_ENABLED, "true", CatalogProperties.URI, uri);
+ S3FileIOProperties.REMOTE_SIGNING_ENABLED,
+ "true",
+ CatalogProperties.URI,
+ uri,
+ RESTCatalogProperties.REMOTE_SIGNING_ENDPOINT,
+ endpoint);
S3FileIOProperties s3Properties = new S3FileIOProperties(properties);
S3ClientBuilder builder = S3Client.builder();
@@ -236,6 +262,7 @@ public class TestS3FileIOProperties {
assertThat(signer).isPresent().get().isInstanceOf(S3V4RestSignerClient.class);
S3V4RestSignerClient signerClient = (S3V4RestSignerClient) signer.get();
assertThat(signerClient.baseSignerUri()).isEqualTo(uri);
+ assertThat(signerClient.endpoint()).isEqualTo(uri + endpoint);
assertThat(signerClient.properties()).isEqualTo(properties);
}
@@ -244,7 +271,12 @@ public class TestS3FileIOProperties {
String uri = "http://localhost:12345";
Map<String, String> properties =
ImmutableMap.of(
- S3FileIOProperties.REMOTE_SIGNING_ENABLED, "true", CatalogProperties.URI, uri);
+ S3FileIOProperties.REMOTE_SIGNING_ENABLED,
+ "true",
+ CatalogProperties.URI,
+ uri,
+ RESTCatalogProperties.REMOTE_SIGNING_ENDPOINT,
+ "v1/namespaces/ns1/tables/t1/sign");
S3FileIOProperties s3Properties = new S3FileIOProperties(properties);
S3ClientBuilder builder = S3Client.builder();
diff --git a/aws/src/test/java/org/apache/iceberg/aws/s3/TestS3FileIOProperties.java b/aws/src/test/java/org/apache/iceberg/aws/s3/TestS3FileIOProperties.java
index 953f73d45d..033a7144f8 100644
--- a/aws/src/test/java/org/apache/iceberg/aws/s3/TestS3FileIOProperties.java
+++ b/aws/src/test/java/org/apache/iceberg/aws/s3/TestS3FileIOProperties.java
@@ -32,6 +32,7 @@ import org.apache.iceberg.exceptions.ValidationException;
import org.apache.iceberg.relocated.com.google.common.collect.ImmutableMap;
import org.apache.iceberg.relocated.com.google.common.collect.Maps;
import org.apache.iceberg.relocated.com.google.common.collect.Sets;
+import org.apache.iceberg.rest.RESTCatalogProperties;
import org.junit.jupiter.api.Test;
import org.mockito.ArgumentCaptor;
import org.mockito.Mockito;
@@ -504,7 +505,9 @@ public class TestS3FileIOProperties {
S3FileIOProperties.REMOTE_SIGNING_ENABLED,
"true",
CatalogProperties.URI,
- "http://localhost:12345");
+ "http://localhost:12345",
+ RESTCatalogProperties.REMOTE_SIGNING_ENDPOINT,
+ "v1/namespaces/ns1/tables/t1/sign");
S3FileIOProperties s3FileIOProperties = new S3FileIOProperties(properties);
S3ClientBuilder mockS3ClientBuilder = Mockito.mock(S3ClientBuilder.class);
s3FileIOProperties.applySignerConfiguration(mockS3ClientBuilder);
diff --git a/aws/src/test/java/org/apache/iceberg/aws/s3/signer/TestS3V4RestSignerClient.java b/aws/src/test/java/org/apache/iceberg/aws/s3/signer/TestS3V4RestSignerClient.java
index aadbf036b5..845855a07a 100644
--- a/aws/src/test/java/org/apache/iceberg/aws/s3/signer/TestS3V4RestSignerClient.java
+++ b/aws/src/test/java/org/apache/iceberg/aws/s3/signer/TestS3V4RestSignerClient.java
@@ -122,19 +122,19 @@ class TestS3V4RestSignerClient {
// No OAuth2 data
Arguments.of(
Map.of(
- RESTCatalogProperties.SIGNER_URI,
+ CatalogProperties.URI,
"https://signer.com",
- RESTCatalogProperties.SIGNER_ENDPOINT,
- "v1/sign/s3"),
+ RESTCatalogProperties.REMOTE_SIGNING_ENDPOINT,
+ "v1/namespaces/ns1/tables/t1/sign"),
"sign",
null),
// Token only
Arguments.of(
Map.of(
- RESTCatalogProperties.SIGNER_URI,
+ CatalogProperties.URI,
"https://signer.com",
- RESTCatalogProperties.SIGNER_ENDPOINT,
- "v1/sign/s3",
+ RESTCatalogProperties.REMOTE_SIGNING_ENDPOINT,
+ "v1/namespaces/ns1/tables/t1/sign",
AuthProperties.AUTH_TYPE,
AuthProperties.AUTH_TYPE_OAUTH2,
OAuth2Properties.TOKEN,
@@ -144,10 +144,10 @@ class TestS3V4RestSignerClient {
// Credential only: expect a token to be fetched
Arguments.of(
Map.of(
- RESTCatalogProperties.SIGNER_URI,
+ CatalogProperties.URI,
"https://signer.com",
- RESTCatalogProperties.SIGNER_ENDPOINT,
- "v1/sign/s3",
+ RESTCatalogProperties.REMOTE_SIGNING_ENDPOINT,
+ "v1/namespaces/ns1/tables/t1/sign",
AuthProperties.AUTH_TYPE,
AuthProperties.AUTH_TYPE_OAUTH2,
OAuth2Properties.CREDENTIAL,
@@ -157,10 +157,10 @@ class TestS3V4RestSignerClient {
// Token and credential: should use token as is, not fetch a new one
Arguments.of(
Map.of(
- RESTCatalogProperties.SIGNER_URI,
+ CatalogProperties.URI,
"https://signer.com",
- RESTCatalogProperties.SIGNER_ENDPOINT,
- "v1/sign/s3",
+ RESTCatalogProperties.REMOTE_SIGNING_ENDPOINT,
+ "v1/namespaces/ns1/tables/t1/sign",
AuthProperties.AUTH_TYPE,
AuthProperties.AUTH_TYPE_OAUTH2,
OAuth2Properties.TOKEN,
@@ -172,10 +172,10 @@ class TestS3V4RestSignerClient {
// Custom scope
Arguments.of(
Map.of(
- RESTCatalogProperties.SIGNER_URI,
+ CatalogProperties.URI,
"https://signer.com",
- RESTCatalogProperties.SIGNER_ENDPOINT,
- "v1/sign/s3",
+ RESTCatalogProperties.REMOTE_SIGNING_ENDPOINT,
+ "v1/namespaces/ns1/tables/t1/sign",
AuthProperties.AUTH_TYPE,
AuthProperties.AUTH_TYPE_OAUTH2,
OAuth2Properties.CREDENTIAL,
@@ -204,11 +204,9 @@ class TestS3V4RestSignerClient {
// Only legacy properties
Arguments.of(
Map.of(
- CatalogProperties.URI,
- "https://catalog.com",
- S3V4RestSignerClient.S3_SIGNER_URI,
+ RESTCatalogProperties.SIGNER_URI,
"https://legacy-signer.com",
- S3V4RestSignerClient.S3_SIGNER_ENDPOINT,
+ RESTCatalogProperties.SIGNER_ENDPOINT,
"v1/legacy/sign"),
"https://legacy-signer.com",
"https://legacy-signer.com/v1/legacy/sign"),
@@ -216,10 +214,8 @@ class TestS3V4RestSignerClient {
Arguments.of(
Map.of(
CatalogProperties.URI,
- "https://catalog.com",
- RESTCatalogProperties.SIGNER_URI,
"https://new-signer.com",
- RESTCatalogProperties.SIGNER_ENDPOINT,
+ RESTCatalogProperties.REMOTE_SIGNING_ENDPOINT,
"v1/new/sign"),
"https://new-signer.com",
"https://new-signer.com/v1/new/sign"),
@@ -227,21 +223,14 @@ class TestS3V4RestSignerClient {
Arguments.of(
Map.of(
CatalogProperties.URI,
- "https://catalog.com",
- RESTCatalogProperties.SIGNER_URI,
"https://new-signer.com",
- RESTCatalogProperties.SIGNER_ENDPOINT,
+ RESTCatalogProperties.REMOTE_SIGNING_ENDPOINT,
"v1/new/sign",
- S3V4RestSignerClient.S3_SIGNER_URI,
+ RESTCatalogProperties.SIGNER_URI,
"https://legacy-signer.com",
- S3V4RestSignerClient.S3_SIGNER_ENDPOINT,
+ RESTCatalogProperties.SIGNER_ENDPOINT,
"v1/legacy/sign"),
"https://legacy-signer.com",
- "https://legacy-signer.com/v1/legacy/sign"),
- // No signer properties: the catalog URI and the deprecated default endpoint are used
- Arguments.of(
- Map.of(CatalogProperties.URI, "https://catalog.com"),
- "https://catalog.com",
- "https://catalog.com/" + S3V4RestSignerClient.S3_SIGNER_DEFAULT_ENDPOINT));
+ "https://legacy-signer.com/v1/legacy/sign"));
}
}
diff --git a/core/src/main/java/org/apache/iceberg/rest/RESTCatalogProperties.java b/core/src/main/java/org/apache/iceberg/rest/RESTCatalogProperties.java
index a5aa10bafc..4180534bd8 100644
--- a/core/src/main/java/org/apache/iceberg/rest/RESTCatalogProperties.java
+++ b/core/src/main/java/org/apache/iceberg/rest/RESTCatalogProperties.java
@@ -100,12 +100,39 @@ public final class RESTCatalogProperties {
/**
* The base URI of the remote signer endpoint. Optional, defaults to {@link
* CatalogProperties#URI}.
+ *
+ * @deprecated since 1.12.0, will be removed in 1.13.0; there is no replacement
*/
- public static final String SIGNER_URI = "signer.uri";
+ @Deprecated public static final String SIGNER_URI = "signer.uri";
/**
* The endpoint path of the remote signer endpoint. If remote signing has been requested, this
* must be set.
+ *
+ * @deprecated since 1.12.0, will be removed in 1.13.0; there is no replacement
*/
- public static final String SIGNER_ENDPOINT = "signer.endpoint";
+ @Deprecated public static final String SIGNER_ENDPOINT = "signer.endpoint";
+
+ /**
+ * The remote signing endpoint path, as computed by {@link
+ * ResourcePaths#remoteSign(org.apache.iceberg.catalog.TableIdentifier)}.
+ *
+ * <p>This property is automatically set by the REST catalog client when creating table-scoped
+ * FileIO instances, and is intended for consumption by remote request signers.
+ *
+ * <p>Even if it's public, this field is not intended for user-facing configuration, and may be
+ * removed or changed in future releases without notice.
+ */
+ public static final String REMOTE_SIGNING_ENDPOINT = "rest.remote-signing.endpoint";
+
+ /**
+ * The {@link RemoteSigningConfig}, JSON-encoded.
+ *
+ * <p>This property is automatically set by the REST catalog client when creating table-scoped
+ * FileIO instances, and is intended for consumption by remote request signers.
+ *
+ * <p>Even if it's public, this field is not intended for user-facing configuration, and may be
+ * removed or changed in future releases without notice.
+ */
+ public static final String REMOTE_SIGNING_CONFIG = "rest.remote-signing.config";
}
diff --git a/core/src/main/java/org/apache/iceberg/rest/RESTSessionCatalog.java b/core/src/main/java/org/apache/iceberg/rest/RESTSessionCatalog.java
index 1d8e9da6d4..8cc5b283b5 100644
--- a/core/src/main/java/org/apache/iceberg/rest/RESTSessionCatalog.java
+++ b/core/src/main/java/org/apache/iceberg/rest/RESTSessionCatalog.java
@@ -557,10 +557,17 @@ public class RESTSessionCatalog extends BaseViewSessionCatalog
}
List<Credential> credentials = response.credentials();
+ RemoteSigningConfig remoteSigningConfig = response.remoteSigningConfig();
RESTClient tableClient = client.withAuthSession(tableSession);
Supplier<BaseTable> tableSupplier =
createTableSupplier(
- finalIdentifier, tableMetadata, context, tableClient, tableConf, credentials);
+ finalIdentifier,
+ tableMetadata,
+ context,
+ tableClient,
+ tableConf,
+ credentials,
+ remoteSigningConfig);
String eTag = responseHeaders.getOrDefault(HttpHeaders.ETAG, null);
if (eTag != null) {
@@ -580,7 +587,8 @@ public class RESTSessionCatalog extends BaseViewSessionCatalog
SessionContext context,
RESTClient tableClient,
Map<String, String> tableConf,
- List<Credential> credentials) {
+ List<Credential> credentials,
+ RemoteSigningConfig remoteSigningConfig) {
return () -> {
RESTTableOperations ops =
newTableOps(
@@ -588,7 +596,7 @@ public class RESTSessionCatalog extends BaseViewSessionCatalog
paths.table(identifier),
Map::of,
mutationHeaders,
- tableFileIO(context, tableConf, credentials),
+ tableFileIO(identifier, context, tableConf, credentials, remoteSigningConfig),
tableMetadata,
endpoints);
@@ -734,7 +742,8 @@ public class RESTSessionCatalog extends BaseViewSessionCatalog
paths.table(ident),
Map::of,
mutationHeaders,
- tableFileIO(context, tableConf, response.credentials()),
+ tableFileIO(
+ ident, context, tableConf, response.credentials(), response.remoteSigningConfig()),
response.tableMetadata(),
endpoints);
@@ -1003,7 +1012,12 @@ public class RESTSessionCatalog extends BaseViewSessionCatalog
paths.table(ident),
Map::of,
mutationHeaders,
- tableFileIO(context, tableConf, response.credentials()),
+ tableFileIO(
+ ident,
+ context,
+ tableConf,
+ response.credentials(),
+ response.remoteSigningConfig()),
response.tableMetadata(),
endpoints);
@@ -1036,7 +1050,12 @@ public class RESTSessionCatalog extends BaseViewSessionCatalog
paths.table(ident),
Map::of,
mutationHeaders,
- tableFileIO(context, tableConf, response.credentials()),
+ tableFileIO(
+ ident,
+ context,
+ tableConf,
+ response.credentials(),
+ response.remoteSigningConfig()),
RESTTableOperations.UpdateType.CREATE,
createChanges(meta),
meta,
@@ -1101,7 +1120,12 @@ public class RESTSessionCatalog extends BaseViewSessionCatalog
paths.table(ident),
Map::of,
mutationHeaders,
- tableFileIO(context, tableConf, response.credentials()),
+ tableFileIO(
+ ident,
+ context,
+ tableConf,
+ response.credentials(),
+ response.remoteSigningConfig()),
RESTTableOperations.UpdateType.REPLACE,
changes.build(),
base,
@@ -1227,14 +1251,35 @@ public class RESTSessionCatalog extends BaseViewSessionCatalog
}
private FileIO tableFileIO(
- SessionContext context, Map<String, String> config, List<Credential> storageCredentials) {
- if (config.isEmpty() && ioBuilder == null && storageCredentials.isEmpty()) {
- return io; // reuse client and io since config/credentials are the same
+ TableIdentifier tableIdentifier,
+ SessionContext context,
+ Map<String, String> tableConf,
+ List<Credential> storageCredentials,
+ RemoteSigningConfig remoteSigningConfig) {
+
+ boolean canReuseCatalogIO =
+ tableConf.isEmpty()
+ && ioBuilder == null
+ && storageCredentials.isEmpty()
+ && remoteSigningConfig.isEmpty();
+
+ if (canReuseCatalogIO) {
+ return io;
}
- Map<String, String> fullConf = RESTUtil.merge(properties(), config);
+ ImmutableMap.Builder<String, String> fullConf =
+ ImmutableMap.<String, String>builder()
+ .putAll(properties())
+ .putAll(tableConf)
+ .put(RESTCatalogProperties.REMOTE_SIGNING_ENDPOINT, paths.remoteSign(tableIdentifier));
+
+ if (!remoteSigningConfig.isEmpty()) {
+ fullConf.put(
+ RESTCatalogProperties.REMOTE_SIGNING_CONFIG,
+ RemoteSigningConfigParser.toJson(remoteSigningConfig));
+ }
- return newFileIO(context, fullConf, storageCredentials);
+ return newFileIO(context, fullConf.buildKeepingLast(), storageCredentials);
}
/**
diff --git a/core/src/main/java/org/apache/iceberg/rest/RemoteSigningConfig.java b/core/src/main/java/org/apache/iceberg/rest/RemoteSigningConfig.java
new file mode 100644
index 0000000000..6cac60250e
--- /dev/null
+++ b/core/src/main/java/org/apache/iceberg/rest/RemoteSigningConfig.java
@@ -0,0 +1,47 @@
+/*
+ * 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.rest;
+
+import java.util.List;
+import java.util.Map;
+import org.immutables.value.Value;
+
+/** Configuration for remote signer clients. */
+@Value.Immutable
+public interface RemoteSigningConfig {
+
+ RemoteSigningConfig EMPTY = ImmutableRemoteSigningConfig.builder().build();
+
+ /**
+ * Static key-value pairs the signer client MUST pass through unchanged in the {@code properties}
+ * field of every {@code RemoteSignRequest} sent to the signing endpoint.
+ */
+ Map<String, String> properties();
+
+ /**
+ * Static headers the signer client MUST include unchanged in every request to the signing
+ * endpoint.
+ */
+ Map<String, List<String>> headers();
+
+ @Value.Derived
+ default boolean isEmpty() {
+ return properties().isEmpty() && headers().isEmpty();
+ }
+}
diff --git a/core/src/main/java/org/apache/iceberg/rest/RemoteSigningConfigParser.java b/core/src/main/java/org/apache/iceberg/rest/RemoteSigningConfigParser.java
new file mode 100644
index 0000000000..ef8b87b25a
--- /dev/null
+++ b/core/src/main/java/org/apache/iceberg/rest/RemoteSigningConfigParser.java
@@ -0,0 +1,84 @@
+/*
+ * 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.rest;
+
+import com.fasterxml.jackson.core.JsonGenerator;
+import com.fasterxml.jackson.databind.JsonNode;
+import java.io.IOException;
+import java.util.List;
+import java.util.Map;
+import org.apache.iceberg.relocated.com.google.common.base.Preconditions;
+import org.apache.iceberg.rest.requests.RemoteSignRequestParser;
+import org.apache.iceberg.util.JsonUtil;
+
+public class RemoteSigningConfigParser {
+
+ private static final String PROPERTIES = "properties";
+ private static final String HEADERS = "headers";
+
+ private RemoteSigningConfigParser() {}
+
+ public static String toJson(RemoteSigningConfig remoteSigningConfig) {
+ return toJson(remoteSigningConfig, false);
+ }
+
+ public static String toJson(RemoteSigningConfig remoteSigningConfig, boolean pretty) {
+ return JsonUtil.generate(gen -> toJson(remoteSigningConfig, gen), pretty);
+ }
+
+ public static void toJson(RemoteSigningConfig remoteSigningConfig, JsonGenerator gen)
+ throws IOException {
+ Preconditions.checkArgument(null != remoteSigningConfig, "Invalid remote signing config: null");
+
+ gen.writeStartObject();
+
+ if (!remoteSigningConfig.headers().isEmpty()) {
+ RemoteSignRequestParser.headersToJson(HEADERS, remoteSigningConfig.headers(), gen);
+ }
+
+ if (!remoteSigningConfig.properties().isEmpty()) {
+ JsonUtil.writeStringMap(PROPERTIES, remoteSigningConfig.properties(), gen);
+ }
+
+ gen.writeEndObject();
+ }
+
+ public static RemoteSigningConfig fromJson(String json) {
+ return JsonUtil.parse(json, RemoteSigningConfigParser::fromJson);
+ }
+
+ public static RemoteSigningConfig fromJson(JsonNode json) {
+ Preconditions.checkArgument(
+ null != json, "Cannot parse remote signing config from null object");
+
+ ImmutableRemoteSigningConfig.Builder builder = ImmutableRemoteSigningConfig.builder();
+
+ if (json.hasNonNull(PROPERTIES)) {
+ Map<String, String> properties = JsonUtil.getStringMap(PROPERTIES, json);
+ builder.properties(properties);
+ }
+
+ if (json.hasNonNull(HEADERS)) {
+ Map<String, List<String>> headers = RemoteSignRequestParser.headersFromJson(HEADERS, json);
+ builder.headers(headers);
+ }
+
+ return builder.build();
+ }
+}
diff --git a/core/src/main/java/org/apache/iceberg/rest/responses/LoadTableResponse.java b/core/src/main/java/org/apache/iceberg/rest/responses/LoadTableResponse.java
index 977220e7d7..a60310236d 100644
--- a/core/src/main/java/org/apache/iceberg/rest/responses/LoadTableResponse.java
+++ b/core/src/main/java/org/apache/iceberg/rest/responses/LoadTableResponse.java
@@ -28,6 +28,7 @@ import org.apache.iceberg.relocated.com.google.common.collect.ImmutableMap;
import org.apache.iceberg.relocated.com.google.common.collect.Lists;
import org.apache.iceberg.relocated.com.google.common.collect.Maps;
import org.apache.iceberg.rest.RESTResponse;
+import org.apache.iceberg.rest.RemoteSigningConfig;
import org.apache.iceberg.rest.credentials.Credential;
/**
@@ -45,6 +46,7 @@ public class LoadTableResponse implements RESTResponse {
private Map<String, String> config;
private TableMetadata metadataWithLocation;
private List<Credential> credentials;
+ private RemoteSigningConfig remoteSigningConfig;
public LoadTableResponse() {
// Required for Jackson deserialization
@@ -54,11 +56,13 @@ public class LoadTableResponse implements RESTResponse {
String metadataLocation,
TableMetadata metadata,
Map<String, String> config,
- List<Credential> credentials) {
+ List<Credential> credentials,
+ RemoteSigningConfig remoteSigningConfig) {
this.metadataLocation = metadataLocation;
this.metadata = metadata;
this.config = config;
this.credentials = credentials;
+ this.remoteSigningConfig = remoteSigningConfig;
}
@Override
@@ -87,6 +91,10 @@ public class LoadTableResponse implements RESTResponse {
return credentials != null ? credentials : ImmutableList.of();
}
+ public RemoteSigningConfig remoteSigningConfig() {
+ return remoteSigningConfig != null ? remoteSigningConfig : RemoteSigningConfig.EMPTY;
+ }
+
@Override
public String toString() {
return MoreObjects.toStringHelper(this)
@@ -105,6 +113,7 @@ public class LoadTableResponse implements RESTResponse {
private TableMetadata metadata;
private final Map<String, String> config = Maps.newHashMap();
private final List<Credential> credentials = Lists.newArrayList();
+ private RemoteSigningConfig remoteSigningConfig = RemoteSigningConfig.EMPTY;
private Builder() {}
@@ -134,9 +143,15 @@ public class LoadTableResponse implements RESTResponse {
return this;
}
+ public Builder withRemoteSigningConfig(RemoteSigningConfig signingConfig) {
+ this.remoteSigningConfig = signingConfig;
+ return this;
+ }
+
public LoadTableResponse build() {
Preconditions.checkNotNull(metadata, "Invalid metadata: null");
- return new LoadTableResponse(metadataLocation, metadata, config, credentials);
+ return new LoadTableResponse(
+ metadataLocation, metadata, config, credentials, remoteSigningConfig);
}
}
}
diff --git a/core/src/main/java/org/apache/iceberg/rest/responses/LoadTableResponseParser.java b/core/src/main/java/org/apache/iceberg/rest/responses/LoadTableResponseParser.java
index 8d34b14983..d53d879bee 100644
--- a/core/src/main/java/org/apache/iceberg/rest/responses/LoadTableResponseParser.java
+++ b/core/src/main/java/org/apache/iceberg/rest/responses/LoadTableResponseParser.java
@@ -24,6 +24,7 @@ import java.io.IOException;
import org.apache.iceberg.TableMetadata;
import org.apache.iceberg.TableMetadataParser;
import org.apache.iceberg.relocated.com.google.common.base.Preconditions;
+import org.apache.iceberg.rest.RemoteSigningConfigParser;
import org.apache.iceberg.rest.credentials.Credential;
import org.apache.iceberg.rest.credentials.CredentialParser;
import org.apache.iceberg.util.JsonUtil;
@@ -34,6 +35,7 @@ public class LoadTableResponseParser {
private static final String METADATA = "metadata";
private static final String CONFIG = "config";
private static final String STORAGE_CREDENTIALS = "storage-credentials";
+ private static final String REMOTE_SIGNING_CONFIG = "remote-signing-config";
private LoadTableResponseParser() {}
@@ -70,6 +72,11 @@ public class LoadTableResponseParser {
gen.writeEndArray();
}
+ if (null != response.remoteSigningConfig() && !response.remoteSigningConfig().isEmpty()) {
+ gen.writeFieldName(REMOTE_SIGNING_CONFIG);
+ RemoteSigningConfigParser.toJson(response.remoteSigningConfig(), gen);
+ }
+
gen.writeEndObject();
}
@@ -101,6 +108,11 @@ public class LoadTableResponseParser {
builder.addAllCredentials(LoadCredentialsResponseParser.fromJson(json).credentials());
}
+ if (json.hasNonNull(REMOTE_SIGNING_CONFIG)) {
+ builder.withRemoteSigningConfig(
+ RemoteSigningConfigParser.fromJson(JsonUtil.get(REMOTE_SIGNING_CONFIG, json)));
+ }
+
return builder.build();
}
}
diff --git a/core/src/test/java/org/apache/iceberg/rest/TestRESTCatalog.java b/core/src/test/java/org/apache/iceberg/rest/TestRESTCatalog.java
index cb100437e4..043ded09d4 100644
--- a/core/src/test/java/org/apache/iceberg/rest/TestRESTCatalog.java
+++ b/core/src/test/java/org/apache/iceberg/rest/TestRESTCatalog.java
@@ -1301,6 +1301,57 @@ public class TestRESTCatalog extends CatalogTests<RESTCatalog> {
assertThat(refsTable.history()).hasSize(numSnapshots);
}
+ @Test
+ public void loadTablePropagatesRemoteSigningConfig() throws IOException {
+ RemoteSigningConfig signingConfig =
+ ImmutableRemoteSigningConfig.builder().putProperties("k", "v").build();
+
+ RESTCatalogAdapter adapter = Mockito.spy(new RESTCatalogAdapter(backendCatalog));
+
+ // Inject signing config into load table responses
+ Mockito.doAnswer(
+ invocation -> {
+ LoadTableResponse response = (LoadTableResponse) invocation.callRealMethod();
+ return LoadTableResponse.builder()
+ .withTableMetadata(response.tableMetadata())
+ .addAllConfig(response.config())
+ .withRemoteSigningConfig(signingConfig)
+ .build();
+ })
+ .when(adapter)
+ .execute(
+ matches(HTTPMethod.GET, RESOURCE_PATHS.table(TABLE)),
+ eq(LoadTableResponse.class),
+ any(),
+ any());
+
+ RESTCatalog catalog =
+ new RESTCatalog(SessionCatalog.SessionContext.createEmpty(), (config) -> adapter);
+ catalog.initialize(
+ "test",
+ ImmutableMap.of(
+ CatalogProperties.URI,
+ "ignored",
+ CatalogProperties.FILE_IO_IMPL,
+ "org.apache.iceberg.inmemory.InMemoryFileIO"));
+
+ if (requiresNamespaceCreate()) {
+ catalog.createNamespace(TABLE.namespace());
+ }
+
+ catalog.createTable(TABLE, SCHEMA);
+
+ Table table = catalog.loadTable(TABLE);
+ FileIO io = table.io();
+
+ assertThat(io.properties())
+ .containsEntry(
+ RESTCatalogProperties.REMOTE_SIGNING_CONFIG,
+ RemoteSigningConfigParser.toJson(signingConfig));
+
+ catalog.close();
+ }
+
@SuppressWarnings("MethodLength")
public void testTableAuth(
String catalogToken,
diff --git a/core/src/test/java/org/apache/iceberg/rest/TestRemoteSigningConfigParser.java b/core/src/test/java/org/apache/iceberg/rest/TestRemoteSigningConfigParser.java
new file mode 100644
index 0000000000..0f328be5b7
--- /dev/null
+++ b/core/src/test/java/org/apache/iceberg/rest/TestRemoteSigningConfigParser.java
@@ -0,0 +1,141 @@
+/*
+ * 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.rest;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+import org.junit.jupiter.api.Test;
+
+class TestRemoteSigningConfigParser {
+
+ @Test
+ void nullCheck() {
+ assertThatThrownBy(() -> RemoteSigningConfigParser.toJson(null))
+ .isInstanceOf(IllegalArgumentException.class)
+ .hasMessage("Invalid remote signing config: null");
+
+ assertThatThrownBy(() -> RemoteSigningConfigParser.fromJson((JsonNode) null))
+ .isInstanceOf(IllegalArgumentException.class)
+ .hasMessage("Cannot parse remote signing config from null object");
+ }
+
+ @Test
+ void roundTripEmpty() {
+ String json = RemoteSigningConfigParser.toJson(RemoteSigningConfig.EMPTY, true);
+ assertThat(json).isEqualTo("{ }");
+ assertThat(RemoteSigningConfigParser.fromJson(json)).isEqualTo(RemoteSigningConfig.EMPTY);
+ }
+
+ @Test
+ void roundTripWithPropertiesOnly() {
+ RemoteSigningConfig config =
+ ImmutableRemoteSigningConfig.builder()
+ .putProperties("k1", "v1")
+ .putProperties("k2", "v2")
+ .build();
+
+ String json = RemoteSigningConfigParser.toJson(config, true);
+ assertThat(json)
+ .isEqualTo(
+ """
+ {
+ "properties" : {
+ "k1" : "v1",
+ "k2" : "v2"
+ }
+ }""");
+ assertThat(RemoteSigningConfigParser.fromJson(json)).isEqualTo(config);
+ }
+
+ @Test
+ void roundTripWithHeadersOnly() {
+ RemoteSigningConfig config =
+ ImmutableRemoteSigningConfig.builder()
+ .putHeaders("Authorization", List.of("Bearer token123"))
+ .putHeaders("X-Custom", Arrays.asList("val1", "val2"))
+ .build();
+
+ String json = RemoteSigningConfigParser.toJson(config, true);
+ assertThat(json)
+ .isEqualTo(
+ """
+ {
+ "headers" : {
+ "Authorization" : [ "Bearer token123" ],
+ "X-Custom" : [ "val1", "val2" ]
+ }
+ }""");
+ assertThat(RemoteSigningConfigParser.fromJson(json)).isEqualTo(config);
+ }
+
+ @Test
+ void roundTripWithPropertiesAndHeaders() {
+ RemoteSigningConfig config =
+ ImmutableRemoteSigningConfig.builder()
+ .properties(Map.of("prop1", "val1"))
+ .headers(Map.of("Authorization", List.of("Bearer token123")))
+ .build();
+
+ String json = RemoteSigningConfigParser.toJson(config, true);
+ assertThat(json)
+ .isEqualTo(
+ """
+ {
+ "headers" : {
+ "Authorization" : [ "Bearer token123" ]
+ },
+ "properties" : {
+ "prop1" : "val1"
+ }
+ }""");
+ assertThat(RemoteSigningConfigParser.fromJson(json)).isEqualTo(config);
+ }
+
+ @Test
+ void isEmpty() {
+ RemoteSigningConfig empty = ImmutableRemoteSigningConfig.builder().build();
+ assertThat(empty.isEmpty()).isTrue();
+
+ RemoteSigningConfig withProps =
+ ImmutableRemoteSigningConfig.builder().properties(Map.of("k", "v")).build();
+ assertThat(withProps.isEmpty()).isFalse();
+
+ RemoteSigningConfig withHeaders =
+ ImmutableRemoteSigningConfig.builder().headers(Map.of("H", List.of("val"))).build();
+ assertThat(withHeaders.isEmpty()).isFalse();
+ }
+
+ @Test
+ void fromJsonIgnoresUnknownFields() {
+ String json =
+ """
+ {
+ "properties" : { "k" : "v" },
+ "unknown-field" : "should-be-ignored"
+ }""";
+ RemoteSigningConfig config = RemoteSigningConfigParser.fromJson(json);
+ assertThat(config.properties()).containsEntry("k", "v");
+ assertThat(config.headers()).isEmpty();
+ }
+}
diff --git a/core/src/test/java/org/apache/iceberg/rest/responses/TestLoadTableResponseParser.java b/core/src/test/java/org/apache/iceberg/rest/responses/TestLoadTableResponseParser.java
index d0a2be263e..3c03f24cf7 100644
--- a/core/src/test/java/org/apache/iceberg/rest/responses/TestLoadTableResponseParser.java
+++ b/core/src/test/java/org/apache/iceberg/rest/responses/TestLoadTableResponseParser.java
@@ -23,11 +23,14 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.assertj.core.api.Assumptions.assumeThat;
import com.fasterxml.jackson.databind.JsonNode;
+import java.util.List;
+import java.util.Map;
import org.apache.iceberg.PartitionSpec;
import org.apache.iceberg.Schema;
import org.apache.iceberg.SortOrder;
import org.apache.iceberg.TableMetadata;
import org.apache.iceberg.relocated.com.google.common.collect.ImmutableMap;
+import org.apache.iceberg.rest.ImmutableRemoteSigningConfig;
import org.apache.iceberg.rest.credentials.ImmutableCredential;
import org.apache.iceberg.types.Types;
import org.junit.jupiter.api.Test;
@@ -356,6 +359,82 @@ public class TestLoadTableResponseParser {
.isEqualTo(expectedJson);
}
+ @Test
+ public void roundTripSerdeWithRemoteSigningConfig() {
+ String uuid = "386b9f01-002b-4d8c-b77f-42c3fd3b7c9b";
+ TableMetadata metadata =
+ TableMetadata.buildFromEmpty()
+ .assignUUID(uuid)
+ .setLocation("location")
+ .setCurrentSchema(
+ new Schema(Types.NestedField.required(1, "x", Types.LongType.get())), 1)
+ .addPartitionSpec(PartitionSpec.unpartitioned())
+ .addSortOrder(SortOrder.unsorted())
+ .discardChanges()
+ .withMetadataLocation("metadata-location")
+ .build();
+
+ LoadTableResponse response =
+ LoadTableResponse.builder()
+ .withTableMetadata(metadata)
+ .withRemoteSigningConfig(
+ ImmutableRemoteSigningConfig.builder()
+ .properties(Map.of("prop1", "val1"))
+ .headers(
+ Map.of(
+ "Authorization",
+ List.of("Bearer token123"),
+ "X-Multi",
+ List.of("a", "b")))
+ .build())
+ .build();
+
+ String json = LoadTableResponseParser.toJson(response, true);
+ assertThat(json).contains("\"remote-signing-config\"");
+ assertThat(json).contains("\"prop1\" : \"val1\"");
+ assertThat(json).contains("\"Authorization\" : [ \"Bearer token123\" ]");
+ assertThat(json).contains("\"X-Multi\" : [ \"a\", \"b\" ]");
+
+ LoadTableResponse roundTripped = LoadTableResponseParser.fromJson(json);
+ assertThat(roundTripped.remoteSigningConfig()).isNotNull();
+ assertThat(roundTripped.remoteSigningConfig().properties()).hasSize(1);
+ assertThat(roundTripped.remoteSigningConfig().properties()).containsEntry("prop1", "val1");
+ assertThat(roundTripped.remoteSigningConfig().headers()).hasSize(2);
+ assertThat(roundTripped.remoteSigningConfig().headers())
+ .containsEntry("Authorization", List.of("Bearer token123"));
+ assertThat(roundTripped.remoteSigningConfig().headers())
+ .containsEntry("X-Multi", List.of("a", "b"));
+ }
+
+ @Test
+ public void roundTripSerdeWithEmptyRemoteSigningConfig() {
+ String uuid = "386b9f01-002b-4d8c-b77f-42c3fd3b7c9b";
+ TableMetadata metadata =
+ TableMetadata.buildFromEmpty()
+ .assignUUID(uuid)
+ .setLocation("location")
+ .setCurrentSchema(
+ new Schema(Types.NestedField.required(1, "x", Types.LongType.get())), 1)
+ .addPartitionSpec(PartitionSpec.unpartitioned())
+ .addSortOrder(SortOrder.unsorted())
+ .discardChanges()
+ .withMetadataLocation("metadata-location")
+ .build();
+
+ LoadTableResponse response =
+ LoadTableResponse.builder()
+ .withTableMetadata(metadata)
+ .withRemoteSigningConfig(ImmutableRemoteSigningConfig.builder().build())
+ .build();
+
+ String json = LoadTableResponseParser.toJson(response, true);
+ assertThat(json).doesNotContain("remote-signing-config");
+
+ LoadTableResponse roundTripped = LoadTableResponseParser.fromJson(json);
+ assertThat(roundTripped.remoteSigningConfig()).isNotNull();
+ assertThat(roundTripped.remoteSigningConfig().isEmpty()).isTrue();
+ }
+
@Test
public void roundTripSerdeWithCredentials() {
String uuid = "386b9f01-002b-4d8c-b77f-42c3fd3b7c9b";