From 7945ed40f0596da2aedd29f831e8671ba4ea0aa2 Mon Sep 17 00:00:00 2001 From: Eric Yang Date: Thu, 16 Apr 2020 12:12:21 -0400 Subject: [PATCH] HADOOP-16361. Fixed TestSecureLogins#testValidKerberosName on branch-2. Contributed by Jim Brennan via eyang --- .../hadoop/registry/secure/TestSecureLogins.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/test/java/org/apache/hadoop/registry/secure/TestSecureLogins.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/test/java/org/apache/hadoop/registry/secure/TestSecureLogins.java index 5592e19ff7b..5150aac9f73 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/test/java/org/apache/hadoop/registry/secure/TestSecureLogins.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/test/java/org/apache/hadoop/registry/secure/TestSecureLogins.java @@ -31,6 +31,7 @@ import org.apache.hadoop.registry.client.impl.zk.RegistrySecurity; import org.apache.hadoop.registry.client.impl.zk.ZookeeperConfigOptions; import org.apache.zookeeper.Environment; import org.apache.zookeeper.data.ACL; +import org.junit.Assert; import org.junit.Assume; import org.junit.Test; import org.slf4j.Logger; @@ -179,10 +180,15 @@ public class TestSecureLogins extends AbstractSecureRegistryTest { public void testValidKerberosName() throws Throwable { new HadoopKerberosName(ZOOKEEPER).getShortName(); - new HadoopKerberosName(ZOOKEEPER_LOCALHOST).getShortName(); new HadoopKerberosName(ZOOKEEPER_REALM).getShortName(); - // standard rules don't pick this up - // new HadoopKerberosName(ZOOKEEPER_LOCALHOST_REALM).getShortName(); + new HadoopKerberosName(ZOOKEEPER_LOCALHOST_REALM).getShortName(); + try { + new HadoopKerberosName(ZOOKEEPER_LOCALHOST).getShortName(); + Assert.fail("Unexpected success for invalid principal: " + + ZOOKEEPER_LOCALHOST); + } catch (IOException e) { + LOG.info("Expected exception: " + e.getMessage()); + } }