2222import org .apache .hadoop .io .Text ;
2323import org .apache .hadoop .minikdc .MiniKdc ;
2424import org .apache .hadoop .security .UserGroupInformation ;
25+ import org .apache .hadoop .security .authentication .KerberosTestUtils ;
2526import org .apache .hadoop .security .authentication .client .AuthenticationException ;
2627import org .apache .hadoop .security .authentication .client .KerberosAuthenticator ;
2728import org .apache .hadoop .security .authentication .server .AuthenticationFilter ;
@@ -743,12 +744,6 @@ private void testKerberosDelegationTokenAuthenticator(
743744 final boolean doAs ) throws Exception {
744745 final String doAsUser = doAs ? OK_USER : null ;
745746
746- // setting hadoop security to kerberos
747- org .apache .hadoop .conf .Configuration conf =
748- new org .apache .hadoop .conf .Configuration ();
749- conf .set ("hadoop.security.authentication" , "kerberos" );
750- UserGroupInformation .setConfiguration (conf );
751-
752747 File testDir = new File ("target/" + UUID .randomUUID ().toString ());
753748 Assert .assertTrue (testDir .mkdirs ());
754749 MiniKdc kdc = new MiniKdc (MiniKdc .createConf (), testDir );
@@ -759,6 +754,10 @@ private void testKerberosDelegationTokenAuthenticator(
759754 context .addFilter (new FilterHolder (KDTAFilter .class ), "/*" ,
760755 EnumSet .of (DispatcherType .REQUEST ));
761756 context .addServlet (new ServletHolder (UserServlet .class ), "/bar" );
757+ org .apache .hadoop .conf .Configuration conf =
758+ new org .apache .hadoop .conf .Configuration ();
759+ conf .set ("hadoop.security.authentication" , "kerberos" );
760+ conf .set ("java.security.krb5.realm" , KerberosTestUtils .getRealm ());
762761 try {
763762 kdc .start ();
764763 File keytabFile = new File (testDir , "test.keytab" );
0 commit comments