steveloughran commented on code in PR #6272:
URL: https://github.com/apache/hadoop/pull/6272#discussion_r1392431111
##########
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/SaslPropertiesResolver.java:
##########
@@ -82,7 +83,7 @@ public Configuration getConf() {
* @return sasl Properties
*/
public Map<String,String> getDefaultProperties() {
- return properties;
+ return new TreeMap<>(properties);
Review Comment:
I'd propose having a private cloneProperties() method used in all calls,
which includes a `requireNonNull()` on the properties...it is null until
setConf() is called.
##########
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/security/TestSaslPropertiesResolver.java:
##########
@@ -0,0 +1,49 @@
+package org.apache.hadoop.security;
+
+import java.net.InetAddress;
+import java.net.InetSocketAddress;
+import javax.security.sasl.Sasl;
+
+import org.junit.Before;
+import org.junit.Test;
+
+import org.apache.hadoop.conf.Configuration;
+
+import static
org.apache.hadoop.fs.CommonConfigurationKeysPublic.HADOOP_RPC_PROTECTION;
+import static org.junit.Assert.assertEquals;
+
+public class TestSaslPropertiesResolver {
Review Comment:
subclass AbstractHadoopTestBase; override it's setup/teardown methods, which
do things like set the thread name
##########
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/security/TestSaslPropertiesResolver.java:
##########
@@ -0,0 +1,49 @@
+package org.apache.hadoop.security;
+
+import java.net.InetAddress;
+import java.net.InetSocketAddress;
+import javax.security.sasl.Sasl;
+
+import org.junit.Before;
+import org.junit.Test;
+
+import org.apache.hadoop.conf.Configuration;
+
+import static
org.apache.hadoop.fs.CommonConfigurationKeysPublic.HADOOP_RPC_PROTECTION;
+import static org.junit.Assert.assertEquals;
+
+public class TestSaslPropertiesResolver {
+
+ private static final SaslRpcServer.QualityOfProtection PRIVACY_QOP =
SaslRpcServer.QualityOfProtection.PRIVACY;
+ private static final SaslRpcServer.QualityOfProtection AUTHENTICATION_QOP =
SaslRpcServer.QualityOfProtection.AUTHENTICATION;
+ private static final InetAddress LOCALHOST = new
InetSocketAddress("127.0.0.1", 1).getAddress();
+
+ private SaslPropertiesResolver resolver;
+
+ @Before
+ public void setup() {
+ Configuration conf = new Configuration();
+ conf.set(HADOOP_RPC_PROTECTION, "privacy");
+ resolver = new SaslPropertiesResolver();
+ resolver.setConf(conf);
+ }
+
+ @Test
+ public void testResolverDoesNotMutate() {
+ assertEquals(PRIVACY_QOP.getSaslQop(),
resolver.getDefaultProperties().get(Sasl.QOP));
Review Comment:
lot of duplication here;
is it possible to factor these out into new assertions? at the very least
some assertPrivacyQop() which is called all the way down.
--
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]