[ https://issues.apache.org/jira/browse/HADOOP-18562?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17952930#comment-17952930 ]
ASF GitHub Bot commented on HADOOP-18562: ----------------------------------------- adideshpande commented on code in PR #7379: URL: https://github.com/apache/hadoop/pull/7379#discussion_r2098515721 ########## hadoop-tools/hadoop-aws/src/test/java/org/apache/hadoop/fs/s3a/impl/TestAwsClientConfig.java: ########## @@ -201,4 +208,64 @@ public void testCreateApiConnectionSettingsDefault() { private void setOptionsToValue(String value, Configuration conf, String... keys) { Arrays.stream(keys).forEach(key -> conf.set(key, value)); } + + /** + * if {@link org.apache.hadoop.fs.s3a.Constants#CUSTOM_HEADERS_STS} is set, + * verify that returned client configuration has desired headers set. + */ + @Test + public void testInitRequestHeadersForSTS() throws IOException { + final Configuration conf = new Configuration(); + conf.set(CUSTOM_HEADERS_STS, "foo=bar;baz,qux=quux"); + Assertions.assertThat(conf.get(CUSTOM_HEADERS_S3)) + .describedAs("Custom client headers for s3 %s", CUSTOM_HEADERS_S3) + .isNull(); + + Assertions.assertThat(createClientConfigBuilder(conf, AWS_SERVICE_IDENTIFIER_S3) + .headers().size()) + .describedAs("Count of S3 client headers") + .isEqualTo(0); + Assertions.assertThat(createClientConfigBuilder(conf, AWS_SERVICE_IDENTIFIER_STS) + .headers().size()) + .describedAs("Count of STS client headers") + .isEqualTo(2); + Assertions.assertThat(createClientConfigBuilder(conf, AWS_SERVICE_IDENTIFIER_STS) + .headers().get("foo")) + .describedAs("STS client 'foo' header value") + .isEqualTo(Lists.newArrayList("bar", "baz")); + Assertions.assertThat(createClientConfigBuilder(conf, AWS_SERVICE_IDENTIFIER_STS) + .headers().get("qux")) + .describedAs("STS client 'qux' header value") + .isEqualTo(Lists.newArrayList("quux")); + } + + /** + * if {@link org.apache.hadoop.fs.s3a.Constants#CUSTOM_HEADERS_S3} is set, + * verify that returned client configuration has desired headers set. + */ + @Test + public void testInitRequestHeadersForS3() throws IOException { + final Configuration conf = new Configuration(); + conf.set(CUSTOM_HEADERS_S3, "foo=bar;baz,qux=quux"); Review Comment: Thanks for the suggestion. It's a good idea to have the header values trimmed and headers without any values should be skipped. So I have updated the logic and unit tests accordingly. > S3A: support custom S3 and STS headers > -------------------------------------- > > Key: HADOOP-18562 > URL: https://issues.apache.org/jira/browse/HADOOP-18562 > Project: Hadoop Common > Issue Type: Sub-task > Components: fs/s3 > Reporter: Daniel Carl Jones > Assignee: Prerak Pradhan > Priority: Minor > Labels: pull-request-available > > Some users have the use case where for a particular S3A filesystem, they > would like to set one or more headers to a static value. > We might imagine a set of configurations properties with a common prefix, > where the suffix determines the header name and the value of the property > determines the value of the header. > Per-filesystem headers can be set using the per-bucket configuration. -- This message was sent by Atlassian Jira (v8.20.10#820010) --------------------------------------------------------------------- To unsubscribe, e-mail: common-issues-unsubscr...@hadoop.apache.org For additional commands, e-mail: common-issues-h...@hadoop.apache.org