Browse Source

HADOOP-8383. Disable TestKerberosAuthenticator. Contributed by Benoy Antony.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-0.22@1346272 13f79535-47bb-0310-9956-ffa450edef68
Konstantin Shvachko 13 years ago
parent
commit
953dff65d2

+ 2 - 0
common/CHANGES.txt

@@ -47,6 +47,8 @@ Release 0.22.1 - Unreleased
     HADOOP-7115. Add a cache for getpwuid_r and getpwgid_r calls.
     (Devaraj Das and Benoy Antony via shv)
 
+    HADOOP-8383. Disable TestKerberosAuthenticator. (Benoy Antony via shv)
+
 Release 0.22.0 - 2011-11-29
 
   INCOMPATIBLE CHANGES

+ 15 - 12
common/src/test/core/org/apache/hadoop/security/authentication/client/AuthenticatorTestCase.java

@@ -13,18 +13,9 @@
  */
 package org.apache.hadoop.security.authentication.client;
 
-import org.apache.hadoop.security.authentication.server.AuthenticationFilter;
-import junit.framework.TestCase;
-import org.mortbay.jetty.Server;
-import org.mortbay.jetty.servlet.Context;
-import org.mortbay.jetty.servlet.FilterHolder;
-import org.mortbay.jetty.servlet.ServletHolder;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
 
-import javax.servlet.FilterConfig;
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServlet;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
 import java.io.BufferedReader;
 import java.io.IOException;
 import java.io.InputStream;
@@ -37,7 +28,19 @@ import java.net.ServerSocket;
 import java.net.URL;
 import java.util.Properties;
 
-public abstract class AuthenticatorTestCase extends TestCase {
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.hadoop.security.authentication.server.AuthenticationFilter;
+import org.mortbay.jetty.Server;
+import org.mortbay.jetty.servlet.Context;
+import org.mortbay.jetty.servlet.FilterHolder;
+import org.mortbay.jetty.servlet.ServletHolder;
+
+public abstract class AuthenticatorTestCase  {
   private Server server;
   private String host = null;
   private int port = -1;

+ 17 - 10
common/src/test/core/org/apache/hadoop/security/authentication/client/TestKerberosAuthenticator.java

@@ -13,17 +13,21 @@
  */
 package org.apache.hadoop.security.authentication.client;
 
-import org.apache.hadoop.security.authentication.KerberosTestUtils;
-import org.apache.hadoop.security.authentication.server.AuthenticationFilter;
-import org.apache.hadoop.security.authentication.server.PseudoAuthenticationHandler;
-import org.apache.hadoop.security.authentication.server.KerberosAuthenticationHandler;
-import org.junit.Ignore;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
 
 import java.net.HttpURLConnection;
 import java.net.URL;
 import java.util.Properties;
 import java.util.concurrent.Callable;
 
+import org.apache.hadoop.security.authentication.KerberosTestUtils;
+import org.apache.hadoop.security.authentication.server.AuthenticationFilter;
+import org.apache.hadoop.security.authentication.server.KerberosAuthenticationHandler;
+import org.apache.hadoop.security.authentication.server.PseudoAuthenticationHandler;
+import org.junit.Ignore;
+import org.junit.Test;
+
 //Disabled because kerberos setup and valid keytabs are required.
 @Ignore("requires kerberos setup")
 public class TestKerberosAuthenticator extends AuthenticatorTestCase {
@@ -37,7 +41,8 @@ public class TestKerberosAuthenticator extends AuthenticatorTestCase {
                       "RULE:[1:$1@$0](.*@" + KerberosTestUtils.getRealm()+")s/@.*//\n");
     return props;
   }
-
+  
+  @Test
   public void testFallbacktoPseudoAuthenticator() throws Exception {
     Properties props = new Properties();
     props.setProperty(AuthenticationFilter.AUTH_TYPE, "simple");
@@ -45,7 +50,8 @@ public class TestKerberosAuthenticator extends AuthenticatorTestCase {
     setAuthenticationHandlerConfig(props);
     _testAuthentication(new KerberosAuthenticator(), false);
   }
-
+  
+  @Test
   public void testNotAuthenticated() throws Exception {
     setAuthenticationHandlerConfig(getAuthenticationHandlerConfiguration());
     start();
@@ -59,8 +65,8 @@ public class TestKerberosAuthenticator extends AuthenticatorTestCase {
       stop();
     }
   }
-
-
+  
+  @Test
   public void testAuthentication() throws Exception {
     setAuthenticationHandlerConfig(getAuthenticationHandlerConfiguration());
     KerberosTestUtils.doAsClient(new Callable<Void>() {
@@ -71,7 +77,8 @@ public class TestKerberosAuthenticator extends AuthenticatorTestCase {
       }
     });
   }
-
+  
+  @Test
   public void testAuthenticationPost() throws Exception {
     setAuthenticationHandlerConfig(getAuthenticationHandlerConfiguration());
     KerberosTestUtils.doAsClient(new Callable<Void>() {

+ 19 - 9
common/src/test/core/org/apache/hadoop/security/authentication/client/TestPseudoAuthenticator.java

@@ -13,13 +13,16 @@
  */
 package org.apache.hadoop.security.authentication.client;
 
-import org.apache.hadoop.security.authentication.server.AuthenticationFilter;
-import org.apache.hadoop.security.authentication.server.PseudoAuthenticationHandler;
+import static org.junit.Assert.assertEquals;
 
 import java.net.HttpURLConnection;
 import java.net.URL;
 import java.util.Properties;
 
+import org.apache.hadoop.security.authentication.server.AuthenticationFilter;
+import org.apache.hadoop.security.authentication.server.PseudoAuthenticationHandler;
+import org.junit.Test;
+
 public class TestPseudoAuthenticator extends AuthenticatorTestCase {
 
   private Properties getAuthenticationHandlerConfiguration(boolean anonymousAllowed) {
@@ -28,12 +31,14 @@ public class TestPseudoAuthenticator extends AuthenticatorTestCase {
     props.setProperty(PseudoAuthenticationHandler.ANONYMOUS_ALLOWED, Boolean.toString(anonymousAllowed));
     return props;
   }
-
+  
+  @Test
   public void testGetUserName() throws Exception {
     PseudoAuthenticator authenticator = new PseudoAuthenticator();
     assertEquals(System.getProperty("user.name"), authenticator.getUserName());
   }
-
+  
+  @Test
   public void testAnonymousAllowed() throws Exception {
     setAuthenticationHandlerConfig(getAuthenticationHandlerConfiguration(true));
     start();
@@ -46,7 +51,8 @@ public class TestPseudoAuthenticator extends AuthenticatorTestCase {
       stop();
     }
   }
-
+  
+  @Test
   public void testAnonymousDisallowed() throws Exception {
     setAuthenticationHandlerConfig(getAuthenticationHandlerConfiguration(false));
     start();
@@ -59,22 +65,26 @@ public class TestPseudoAuthenticator extends AuthenticatorTestCase {
       stop();
     }
   }
-
+  
+  @Test
   public void testAuthenticationAnonymousAllowed() throws Exception {
     setAuthenticationHandlerConfig(getAuthenticationHandlerConfiguration(true));
     _testAuthentication(new PseudoAuthenticator(), false);
   }
-
+  
+  @Test
   public void testAuthenticationAnonymousDisallowed() throws Exception {
     setAuthenticationHandlerConfig(getAuthenticationHandlerConfiguration(false));
     _testAuthentication(new PseudoAuthenticator(), false);
   }
-
+  
+  @Test
   public void testAuthenticationAnonymousAllowedWithPost() throws Exception {
     setAuthenticationHandlerConfig(getAuthenticationHandlerConfiguration(true));
     _testAuthentication(new PseudoAuthenticator(), true);
   }
-
+  
+  @Test
   public void testAuthenticationAnonymousDisallowedWithPost() throws Exception {
     setAuthenticationHandlerConfig(getAuthenticationHandlerConfiguration(false));
     _testAuthentication(new PseudoAuthenticator(), true);

+ 34 - 21
common/src/test/core/org/apache/hadoop/security/authentication/server/TestKerberosAuthenticationHandler.java

@@ -13,32 +13,40 @@
  */
 package org.apache.hadoop.security.authentication.server;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.util.Properties;
+import java.util.concurrent.Callable;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.commons.codec.binary.Base64;
 import org.apache.hadoop.security.authentication.KerberosTestUtils;
 import org.apache.hadoop.security.authentication.client.AuthenticationException;
 import org.apache.hadoop.security.authentication.client.KerberosAuthenticator;
-import junit.framework.TestCase;
-import org.apache.commons.codec.binary.Base64;
 import org.ietf.jgss.GSSContext;
 import org.ietf.jgss.GSSManager;
 import org.ietf.jgss.GSSName;
+import org.junit.After;
+import org.junit.Before;
 import org.junit.Ignore;
+import org.junit.Test;
 import org.mockito.Mockito;
-import sun.security.jgss.GSSUtil;
 
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.util.Properties;
-import java.util.concurrent.Callable;
+import sun.security.jgss.GSSUtil;
 
 //Disabled because kerberos setup and valid keytabs are required.
 @Ignore("requires kerberos setup")
-public class TestKerberosAuthenticationHandler extends TestCase {
+public class TestKerberosAuthenticationHandler  {
 
   private KerberosAuthenticationHandler handler;
 
-  @Override
-  protected void setUp() throws Exception {
-    super.setUp();
+  @Before
+  public void setUp() throws Exception {
     handler = new KerberosAuthenticationHandler();
     Properties props = new Properties();
     props.setProperty(KerberosAuthenticationHandler.PRINCIPAL, KerberosTestUtils.getServerPrincipal());
@@ -53,25 +61,27 @@ public class TestKerberosAuthenticationHandler extends TestCase {
     }
   }
 
-  @Override
-  protected void tearDown() throws Exception {
+  @After
+  public void tearDown() throws Exception {
     if (handler != null) {
       handler.destroy();
       handler = null;
     }
-    super.tearDown();
   }
-
+  
+  @Test
   public void testInit() throws Exception {
     assertEquals(KerberosTestUtils.getServerPrincipal(), handler.getPrincipal());
     assertEquals(KerberosTestUtils.getKeytabFile(), handler.getKeytab());
   }
-
+  
+  @Test
   public void testType() throws Exception {
     KerberosAuthenticationHandler handler = new KerberosAuthenticationHandler();
     assertEquals(KerberosAuthenticationHandler.TYPE, handler.getType());
   }
-
+  
+  @Test
   public void testRequestWithoutAuthorization() throws Exception {
     HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
     HttpServletResponse response = Mockito.mock(HttpServletResponse.class);
@@ -80,7 +90,8 @@ public class TestKerberosAuthenticationHandler extends TestCase {
     Mockito.verify(response).setHeader(KerberosAuthenticator.WWW_AUTHENTICATE, KerberosAuthenticator.NEGOTIATE);
     Mockito.verify(response).setStatus(HttpServletResponse.SC_UNAUTHORIZED);
   }
-
+  
+  @Test
   public void testRequestWithInvalidAuthorization() throws Exception {
     HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
     HttpServletResponse response = Mockito.mock(HttpServletResponse.class);
@@ -90,7 +101,8 @@ public class TestKerberosAuthenticationHandler extends TestCase {
     Mockito.verify(response).setHeader(KerberosAuthenticator.WWW_AUTHENTICATE, KerberosAuthenticator.NEGOTIATE);
     Mockito.verify(response).setStatus(HttpServletResponse.SC_UNAUTHORIZED);
   }
-
+  
+  @Test
   public void testRequestWithIncompleteAuthorization() throws Exception {
     HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
     HttpServletResponse response = Mockito.mock(HttpServletResponse.class);
@@ -107,7 +119,7 @@ public class TestKerberosAuthenticationHandler extends TestCase {
     }
   }
 
-
+  @Test
   public void testRequestWithAuthorization() throws Exception {
     String token = KerberosTestUtils.doAsClient(new Callable<String>() {
       @Override
@@ -157,7 +169,8 @@ public class TestKerberosAuthenticationHandler extends TestCase {
       Mockito.verify(response).setStatus(HttpServletResponse.SC_UNAUTHORIZED);
     }
   }
-
+  
+  @Test
   public void testRequestWithInvalidKerberosAuthorization() throws Exception {
 
     String token = new Base64(0).encodeToString(new byte[]{0, 1, 2});