ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rle...@apache.org
Subject ambari git commit: AMBARI-22293. Improve KDC integration [addendum - fix unit tests] (rlevas)
Date Wed, 08 Nov 2017 17:26:11 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk 0f67d1c69 -> 08d382652


AMBARI-22293.  Improve KDC integration [addendum - fix unit tests] (rlevas)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/08d38265
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/08d38265
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/08d38265

Branch: refs/heads/trunk
Commit: 08d382652052172aeb15082a919a18666de93eb7
Parents: 0f67d1c
Author: Robert Levas <rlevas@hortonworks.com>
Authored: Wed Nov 8 12:26:00 2017 -0500
Committer: Robert Levas <rlevas@hortonworks.com>
Committed: Wed Nov 8 12:26:00 2017 -0500

----------------------------------------------------------------------
 .../KDCKerberosOperationHandlerTest.java        | 22 +++++++++++++++++---
 .../MITKerberosOperationHandlerTest.java        |  6 +++---
 2 files changed, 22 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/08d38265/ambari-server/src/test/java/org/apache/ambari/server/serveraction/kerberos/KDCKerberosOperationHandlerTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/serveraction/kerberos/KDCKerberosOperationHandlerTest.java
b/ambari-server/src/test/java/org/apache/ambari/server/serveraction/kerberos/KDCKerberosOperationHandlerTest.java
index 271c787..095b92a 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/serveraction/kerberos/KDCKerberosOperationHandlerTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/serveraction/kerberos/KDCKerberosOperationHandlerTest.java
@@ -19,7 +19,9 @@
 package org.apache.ambari.server.serveraction.kerberos;
 
 import static org.easymock.EasyMock.anyObject;
+import static org.easymock.EasyMock.anyString;
 import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.getCurrentArguments;
 
 import java.lang.reflect.Method;
 import java.util.Map;
@@ -27,6 +29,7 @@ import java.util.Map;
 import org.apache.ambari.server.utils.ShellCommandUtil;
 import org.apache.commons.lang.StringUtils;
 import org.easymock.EasyMock;
+import org.easymock.IAnswer;
 import org.easymock.IArgumentMatcher;
 import org.junit.BeforeClass;
 import org.junit.Test;
@@ -37,9 +40,12 @@ abstract public class KDCKerberosOperationHandlerTest extends KerberosOperationH
 
   static Method methodExecuteCommand;
 
+  static Method methodGetExecutable;
+
   @BeforeClass
   public static void beforeKDCKerberosOperationHandlerTest() throws Exception {
     methodExecuteCommand = KDCKerberosOperationHandler.class.getDeclaredMethod("executeCommand",
String[].class, Map.class, ShellCommandUtil.InteractiveHandler.class);
+    methodGetExecutable = KerberosOperationHandler.class.getDeclaredMethod("getExecutable",
String.class);
   }
 
   @Test
@@ -66,7 +72,17 @@ abstract public class KDCKerberosOperationHandlerTest extends KerberosOperationH
 
   @Override
   protected KerberosOperationHandler createMockedHandler() throws KerberosOperationException
{
-    return createMockedHandler(methodExecuteCommand);
+    KDCKerberosOperationHandler handler = createMockedHandler(methodExecuteCommand, methodGetExecutable);
+
+    expect(handler.getExecutable(anyString()))
+        .andAnswer(new IAnswer<String>() {
+          @Override
+          public String answer() throws Throwable {
+            Object[] args = getCurrentArguments();
+            return args[0].toString();
+          }
+        }).anyTimes();
+    return handler;
   }
 
   @Override
@@ -74,7 +90,7 @@ abstract public class KDCKerberosOperationHandlerTest extends KerberosOperationH
     ShellCommandUtil.Result result = createMock(ShellCommandUtil.Result.class);
     expect(result.isSuccessful()).andReturn(true);
 
-    expect(handler.executeCommand(arrayContains("/usr/bin/kinit"), anyObject(Map.class),
anyObject(KDCKerberosOperationHandler.InteractivePasswordHandler.class)))
+    expect(handler.executeCommand(arrayContains("kinit"), anyObject(Map.class), anyObject(KDCKerberosOperationHandler.InteractivePasswordHandler.class)))
         .andReturn(result)
         .anyTimes();
   }
@@ -87,7 +103,7 @@ abstract public class KDCKerberosOperationHandlerTest extends KerberosOperationH
     expect(result.getStdout()).andReturn("STDOUT data").once();
     expect(result.getStderr()).andReturn("STDERR data").once();
 
-    expect(handler.executeCommand(arrayContains("/usr/bin/kinit"), anyObject(Map.class),
anyObject(KDCKerberosOperationHandler.InteractivePasswordHandler.class)))
+    expect(handler.executeCommand(arrayContains("kinit"), anyObject(Map.class), anyObject(KDCKerberosOperationHandler.InteractivePasswordHandler.class)))
         .andReturn(result)
         .anyTimes();
   }

http://git-wip-us.apache.org/repos/asf/ambari/blob/08d38265/ambari-server/src/test/java/org/apache/ambari/server/serveraction/kerberos/MITKerberosOperationHandlerTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/serveraction/kerberos/MITKerberosOperationHandlerTest.java
b/ambari-server/src/test/java/org/apache/ambari/server/serveraction/kerberos/MITKerberosOperationHandlerTest.java
index 848d479..f94adbe 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/serveraction/kerberos/MITKerberosOperationHandlerTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/serveraction/kerberos/MITKerberosOperationHandlerTest.java
@@ -275,7 +275,7 @@ public class MITKerberosOperationHandlerTest extends KDCKerberosOperationHandler
         .andReturn("Authenticating as principal admin/admin with password.")
         .anyTimes();
 
-    expect(handler.executeCommand(arrayContains(new String[]{"/usr/sbin/kadmin", "add_principal"}),
anyObject(Map.class), anyObject(KDCKerberosOperationHandler.InteractivePasswordHandler.class)))
+    expect(handler.executeCommand(arrayContains(new String[]{"kadmin", "add_principal"}),
anyObject(Map.class), anyObject(KDCKerberosOperationHandler.InteractivePasswordHandler.class)))
         .andReturn(result)
         .anyTimes();
   }
@@ -292,7 +292,7 @@ public class MITKerberosOperationHandlerTest extends KDCKerberosOperationHandler
         .andReturn("Authenticating as principal admin/admin with password.")
         .anyTimes();
 
-    expect(handler.executeCommand(arrayContains(new String[]{"/usr/sbin/kadmin", "get_principal"}),
anyObject(Map.class), anyObject(KDCKerberosOperationHandler.InteractivePasswordHandler.class)))
+    expect(handler.executeCommand(arrayContains(new String[]{"kadmin", "get_principal"}),
anyObject(Map.class), anyObject(KDCKerberosOperationHandler.InteractivePasswordHandler.class)))
         .andReturn(result)
         .anyTimes();
   }
@@ -329,7 +329,7 @@ public class MITKerberosOperationHandlerTest extends KDCKerberosOperationHandler
             "Policy: [none]", (service) ? "service/host" : "user"))
         .anyTimes();
 
-    expect(handler.executeCommand(arrayContains(new String[]{"/usr/sbin/kadmin", "get_principal"}),
anyObject(Map.class), anyObject(KDCKerberosOperationHandler.InteractivePasswordHandler.class)))
+    expect(handler.executeCommand(arrayContains(new String[]{"kadmin", "get_principal"}),
anyObject(Map.class), anyObject(KDCKerberosOperationHandler.InteractivePasswordHandler.class)))
         .andReturn(result)
         .anyTimes();
   }


Mime
View raw message