steveloughran commented on a change in pull request #1332: HADOOP-16445. Allow
separate custom signing algorithms for S3 and DDB
URL: https://github.com/apache/hadoop/pull/1332#discussion_r324781956
##########
File path:
hadoop-tools/hadoop-aws/src/test/java/org/apache/hadoop/fs/s3a/ITestS3AConfiguration.java
##########
@@ -617,4 +624,135 @@ public void testSecurityCredentialPropagationEndToEnd()
throws Exception {
"override,base");
}
+ @Test(timeout = 10_000L)
+ public void testS3SpecificSignerOverride() throws IOException {
+ ClientConfiguration clientConfiguration = null;
+ Configuration config;
+
+ String signerOverride = "testSigner";
+ String s3SignerOverride = "testS3Signer";
+
+ // Default SIGNING_ALGORITHM, overridden for S3 only
+ config = new Configuration();
+ config.set(SIGNING_ALGORITHM_S3, s3SignerOverride);
+ clientConfiguration = S3AUtils.createAwsConfForS3(config, "dontcare");
+ Assert.assertEquals(s3SignerOverride,
+ clientConfiguration.getSignerOverride());
+ clientConfiguration = S3AUtils.createAwsConfForDdb(config, "dontcare");
+ Assert.assertNull(clientConfiguration.getSignerOverride());
+
+ // Configured base SIGNING_ALGORITHM, overridden for S3 only
+ config = new Configuration();
+ config.set(SIGNING_ALGORITHM, signerOverride);
+ config.set(SIGNING_ALGORITHM_S3, s3SignerOverride);
+ clientConfiguration = S3AUtils.createAwsConfForS3(config, "dontcare");
+ Assert.assertEquals(s3SignerOverride,
+ clientConfiguration.getSignerOverride());
+ clientConfiguration = S3AUtils.createAwsConfForDdb(config, "dontcare");
+ Assert
+ .assertEquals(signerOverride, clientConfiguration.getSignerOverride());
+ }
+
+ @Test(timeout = 10_000L)
+ public void testDdbSpecificSignerOverride() throws IOException {
+ ClientConfiguration clientConfiguration = null;
+ Configuration config;
+
+ String signerOverride = "testSigner";
+ String ddbSignerOverride = "testDdbSigner";
+
+ // Default SIGNING_ALGORITHM, overridden for S3
+ config = new Configuration();
+ config.set(SIGNING_ALGORITHM_DDB, ddbSignerOverride);
+ clientConfiguration = S3AUtils.createAwsConfForDdb(config, "dontcare");
+ Assert.assertEquals(ddbSignerOverride,
+ clientConfiguration.getSignerOverride());
+ clientConfiguration = S3AUtils.createAwsConfForS3(config, "dontcare");
+ Assert.assertNull(clientConfiguration.getSignerOverride());
+
+ // Configured base SIGNING_ALGORITHM, overridden for S3
+ config = new Configuration();
+ config.set(SIGNING_ALGORITHM, signerOverride);
+ config.set(SIGNING_ALGORITHM_DDB, ddbSignerOverride);
+ clientConfiguration = S3AUtils.createAwsConfForDdb(config, "dontcare");
+ Assert.assertEquals(ddbSignerOverride,
+ clientConfiguration.getSignerOverride());
+ clientConfiguration = S3AUtils.createAwsConfForS3(config, "dontcare");
+ Assert
+ .assertEquals(signerOverride, clientConfiguration.getSignerOverride());
+ }
+
+ // Expecting generic Exception.class to handle future implementation changes.
+ // For now, this is an NPE
+ @Test(timeout = 10_000L, expected = Exception.class)
+ public void testCustomSignerFailureIfNotRegistered() {
+ Signer s1 = SignerFactory.createSigner("testsigner1", null);
Review comment:
Prefer `LambaTestUtils.intercept` which lets you assert the text of the
caught exception, and which includes the toString value of the result of the
l-expression when it did not fail
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]