nastra commented on code in PR #12595:
URL: https://github.com/apache/iceberg/pull/12595#discussion_r2016030409
##########
core/src/test/java/org/apache/iceberg/rest/TestRESTCatalog.java:
##########
@@ -332,6 +330,27 @@ public void testInitializeWithBadArguments() throws
IOException {
restCat.close();
}
+ @Test
+ public void testCatalogProperties() {
Review Comment:
I was thinking of something similar to this, where we provide a custom
client that we spy on and check what headers are sent:
```
@Test
public void testDefaultHeadersPropagated() {
Map<String, String> catalogHeaders =
ImmutableMap.of("Authorization", "Bearer
client-credentials-token:sub=catalog");
Map<String, String> properties =
ImmutableMap.of(
"header.test-header",
"test-value",
CatalogProperties.URI,
httpServer.getURI().toString());
Map<String, String> expectedHeaders = ImmutableMap.of("test-header",
"test-value");
HTTPClient client =
Mockito.spy(
HTTPClient.builder(properties)
.withHeaders(RESTUtil.merge(RESTUtil.configHeaders(properties), catalogHeaders))
.uri(properties.get(CatalogProperties.URI))
.build());
RESTCatalog catalog =
new RESTCatalog(SessionCatalog.SessionContext.createEmpty(),
(config) -> client);
catalog.initialize("test", properties);
assertThat(catalog.namespaceExists(Namespace.of("non-existing"))).isFalse();
Mockito.verify(client)
.execute(
reqMatcher(HTTPMethod.GET, "v1/config", expectedHeaders,
Map.of()),
eq(ConfigResponse.class),
any(),
any());
Mockito.verify(client)
.execute(
reqMatcher(HTTPMethod.HEAD, "v1/namespaces/non-existing",
expectedHeaders, Map.of()),
any(),
any(),
any());
}
```
I haven't executed/tried this, so you might need to tune/adjust this test a
little bit
--
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]