From 44bc095998c7c09335c9b663f0d154fed0508f56 Mon Sep 17 00:00:00 2001 From: Ayush Saxena Date: Sat, 12 Oct 2019 13:16:51 +0530 Subject: [PATCH] HADOOP-13907. Fix TestWebDelegationToken#testKerberosDelegationTokenAuthenticator on Windows. Contributed by Kitti Nanasi. --- .../token/delegation/web/TestWebDelegationToken.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/security/token/delegation/web/TestWebDelegationToken.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/security/token/delegation/web/TestWebDelegationToken.java index 1fcc6faac6..9b5bd22dbe 100644 --- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/security/token/delegation/web/TestWebDelegationToken.java +++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/security/token/delegation/web/TestWebDelegationToken.java @@ -22,6 +22,7 @@ import org.apache.hadoop.io.Text; import org.apache.hadoop.minikdc.MiniKdc; import org.apache.hadoop.security.UserGroupInformation; +import org.apache.hadoop.security.authentication.KerberosTestUtils; import org.apache.hadoop.security.authentication.client.AuthenticationException; import org.apache.hadoop.security.authentication.client.KerberosAuthenticator; import org.apache.hadoop.security.authentication.server.AuthenticationFilter; @@ -743,12 +744,6 @@ private void testKerberosDelegationTokenAuthenticator( final boolean doAs) throws Exception { final String doAsUser = doAs ? OK_USER : null; - // setting hadoop security to kerberos - org.apache.hadoop.conf.Configuration conf = - new org.apache.hadoop.conf.Configuration(); - conf.set("hadoop.security.authentication", "kerberos"); - UserGroupInformation.setConfiguration(conf); - File testDir = new File("target/" + UUID.randomUUID().toString()); Assert.assertTrue(testDir.mkdirs()); MiniKdc kdc = new MiniKdc(MiniKdc.createConf(), testDir); @@ -759,6 +754,10 @@ private void testKerberosDelegationTokenAuthenticator( context.addFilter(new FilterHolder(KDTAFilter.class), "/*", EnumSet.of(DispatcherType.REQUEST)); context.addServlet(new ServletHolder(UserServlet.class), "/bar"); + org.apache.hadoop.conf.Configuration conf = + new org.apache.hadoop.conf.Configuration(); + conf.set("hadoop.security.authentication", "kerberos"); + conf.set("java.security.krb5.realm", KerberosTestUtils.getRealm()); try { kdc.start(); File keytabFile = new File(testDir, "test.keytab");