wolflex888 commented on code in PR #12595: URL: https://github.com/apache/iceberg/pull/12595#discussion_r2022056893
########## core/src/test/java/org/apache/iceberg/rest/TestRESTCatalog.java: ########## @@ -332,6 +343,46 @@ public void testInitializeWithBadArguments() throws IOException { restCat.close(); } + @Test + public void testDefaultHeadersPropagated() throws IOException { + Map<String, String> catalogHeaders = + ImmutableMap.of("Authorization", "Bearer client-credentials-token:sub=general"); + + Map<String, String> properties = + ImmutableMap.of( + "header.X-Iceberg-Access-Delegation", + "vended-credential", + CatalogProperties.URI, + httpServer.getURI().toString()); + HTTPHeaders.HTTPHeader expectedHeader = + HTTPHeaders.HTTPHeader.of("X-Iceberg-Access-Delegation", "vended-credential"); + HTTPClient client = + Mockito.spy( + HTTPClient.builder(properties) + .withHeaders(RESTUtil.merge(RESTUtil.configHeaders(properties), catalogHeaders)) + .uri(properties.get(CatalogProperties.URI)) + .build()); + Mockito.doNothing().when(client).close(); + 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( + reqContainsHeader(HTTPMethod.GET, "v1/config", expectedHeader, Map.of()), Review Comment: hmm it will involve `X-Client-Git-Commit-Short` and `X-Client-Version` so the test is not only testing header propagation from configs, but also the ones from client itself. -- 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-unsubscr...@iceberg.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org For additional commands, e-mail: issues-h...@iceberg.apache.org