szetszwo commented on code in PR #7005:
URL: https://github.com/apache/hadoop/pull/7005#discussion_r1722173386
##########
hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/protocol/datatransfer/sasl/TestCustomizedCallbackHandler.java:
##########
@@ -60,4 +60,30 @@ public void testCustomizedCallbackHandler() throws Exception
{
MyCallbackHandler.class, CustomizedCallbackHandler.class);
new SaslServerCallbackHandler(conf, String::toCharArray).handle(callbacks);
}
+
+ static class MyCallbackMethod {
+ public void handleCallback(List<Callback> callbacks, String name, char[]
password)
+ throws UnsupportedCallbackException {
+ LOG.info("{}: handling {} for {}", getClass().getSimpleName(),
callbacks, name);
+ }
+ }
+
+ @Test
+ public void testCustomizedCallbackMethod() throws Exception {
+ final Configuration conf = new Configuration();
+ final Callback[] callbacks = {new MyCallback()};
+
+ // without setting conf, expect UnsupportedCallbackException
+ try {
+ new SaslServerCallbackHandler(conf,
String::toCharArray).handle(callbacks);
+ Assert.fail("Expected UnsupportedCallbackException for " +
Arrays.asList(callbacks));
+ } catch (UnsupportedCallbackException e) {
+ LOG.info("The failure is expected", e);
+ }
+
+ // set conf and expect success
+
conf.setClass(HdfsClientConfigKeys.DFS_DATA_TRANSFER_SASL_CUSTOMIZEDCALLBACKHANDLER_CLASS_KEY,
+ MyCallbackMethod.class, Object.class);
+ new SaslServerCallbackHandler(conf, String::toCharArray).handle(callbacks);
Review Comment:
Sure, will add both.
--
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]