nastra commented on code in PR #12595: URL: https://github.com/apache/iceberg/pull/12595#discussion_r2021097591
########## 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: wouldn't it be easier to just pass a Map of expected headers instead of introducing a new method to match only a single header? -- 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