You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by rl...@apache.org on 2015/04/10 18:31:22 UTC
ambari git commit: AMBARI-10053. The path(s) to the Kerberos
utilities (kadmin, klist, etc...) should be configurable (rlevas)
Repository: ambari
Updated Branches:
refs/heads/branch-2.0.maint cd65c7a22 -> 5fcfb6ab9
AMBARI-10053. The path(s) to the Kerberos utilities (kadmin, klist, etc...) should be configurable (rlevas)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/5fcfb6ab
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/5fcfb6ab
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/5fcfb6ab
Branch: refs/heads/branch-2.0.maint
Commit: 5fcfb6ab998b663742d7f6cf1db38d824aa93815
Parents: cd65c7a
Author: Robert Levas <rl...@hortonworks.com>
Authored: Tue Mar 24 06:30:52 2015 -0400
Committer: Robert Levas <rl...@hortonworks.com>
Committed: Fri Apr 10 12:29:04 2015 -0400
----------------------------------------------------------------------
.../libraries/functions/__init__.py | 1 +
.../libraries/functions/find_executable.py | 48 +++++++++
.../libraries/functions/find_path.py | 2 +-
.../libraries/functions/get_kdestroy_path.py | 14 +--
.../libraries/functions/get_kinit_path.py | 14 +--
.../libraries/functions/get_klist_path.py | 14 +--
.../kerberos/KerberosOperationHandler.java | 103 +++++++++++++++++++
.../kerberos/MITKerberosOperationHandler.java | 54 +++++-----
.../1.10.3-10/configuration/kerberos-env.xml | 7 ++
.../kerberos/KerberosOperationHandlerTest.java | 45 ++++++++
.../MITKerberosOperationHandlerTest.java | 24 -----
11 files changed, 254 insertions(+), 72 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/5fcfb6ab/ambari-common/src/main/python/resource_management/libraries/functions/__init__.py
----------------------------------------------------------------------
diff --git a/ambari-common/src/main/python/resource_management/libraries/functions/__init__.py b/ambari-common/src/main/python/resource_management/libraries/functions/__init__.py
index f6db722..d6e84fd 100644
--- a/ambari-common/src/main/python/resource_management/libraries/functions/__init__.py
+++ b/ambari-common/src/main/python/resource_management/libraries/functions/__init__.py
@@ -25,6 +25,7 @@ import platform
from resource_management.libraries.functions.default import *
from resource_management.libraries.functions.format import *
from resource_management.libraries.functions.find_path import *
+from resource_management.libraries.functions.find_executable import *
from resource_management.libraries.functions.get_kinit_path import *
from resource_management.libraries.functions.get_kdestroy_path import *
from resource_management.libraries.functions.get_klist_path import *
http://git-wip-us.apache.org/repos/asf/ambari/blob/5fcfb6ab/ambari-common/src/main/python/resource_management/libraries/functions/find_executable.py
----------------------------------------------------------------------
diff --git a/ambari-common/src/main/python/resource_management/libraries/functions/find_executable.py b/ambari-common/src/main/python/resource_management/libraries/functions/find_executable.py
new file mode 100644
index 0000000..ad5eb0c
--- /dev/null
+++ b/ambari-common/src/main/python/resource_management/libraries/functions/find_executable.py
@@ -0,0 +1,48 @@
+#!/usr/bin/env python
+"""
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+Ambari Agent
+
+"""
+
+__all__ = ["find_executable"]
+from find_path import find_path
+
+
+def find_executable(search_directories, filename):
+ """
+ Searches for the specified executable using a list of specified search paths or, if None, a default
+ set of paths:
+ /usr/bin
+ /usr/kerberos/bin
+ /usr/sbin
+ /usr/lib/mit/bin
+ /usr/lib/mit/sbin
+
+ @param search_directories: comma separated list or a list of (absolute paths to) directories to search (in order of preference)
+ @param filename: the name of the file for which to search
+ """
+ if isinstance(search_directories, unicode):
+ search_directories = map(str.strip, search_directories.encode("ascii").split(","))
+ elif isinstance(search_directories, str):
+ search_directories = map(str.strip, search_directories.split(","))
+ elif not isinstance(search_directories, list):
+ search_directories = ["/usr/bin", "/usr/kerberos/bin", "/usr/sbin", '/usr/lib/mit/bin',
+ '/usr/lib/mit/sbin']
+
+ return find_path(search_directories, filename)
http://git-wip-us.apache.org/repos/asf/ambari/blob/5fcfb6ab/ambari-common/src/main/python/resource_management/libraries/functions/find_path.py
----------------------------------------------------------------------
diff --git a/ambari-common/src/main/python/resource_management/libraries/functions/find_path.py b/ambari-common/src/main/python/resource_management/libraries/functions/find_path.py
index 52a5044..45f2269 100644
--- a/ambari-common/src/main/python/resource_management/libraries/functions/find_path.py
+++ b/ambari-common/src/main/python/resource_management/libraries/functions/find_path.py
@@ -26,7 +26,7 @@ import os
def find_path(search_directories, filename):
"""
- @param search_directories: comma separated list of (absolute paths to) directories to search (in order of preference)
+ @param search_directories: comma separated list or a list of (absolute paths to) directories to search (in order of preference)
@param filename: the name of the file for which to search
"""
path = ""
http://git-wip-us.apache.org/repos/asf/ambari/blob/5fcfb6ab/ambari-common/src/main/python/resource_management/libraries/functions/get_kdestroy_path.py
----------------------------------------------------------------------
diff --git a/ambari-common/src/main/python/resource_management/libraries/functions/get_kdestroy_path.py b/ambari-common/src/main/python/resource_management/libraries/functions/get_kdestroy_path.py
index 085ba6a..cf13e2e 100644
--- a/ambari-common/src/main/python/resource_management/libraries/functions/get_kdestroy_path.py
+++ b/ambari-common/src/main/python/resource_management/libraries/functions/get_kdestroy_path.py
@@ -21,14 +21,14 @@ Ambari Agent
"""
__all__ = ["get_kdestroy_path"]
-from find_path import find_path
+from find_executable import find_executable
-def get_kdestroy_path():
+def get_kdestroy_path(search_directories=None):
"""
- Searches for the kdestroy executable using a default set of of paths to search:
- /usr/bin
- /usr/kerberos/bin
- /usr/sbin
+ Searches for the kdestroy executable using the specified search paths or a default set of of paths to search
+
+ @param search_directories: comma separated list or a list of (absolute paths to) directories to search (in order of preference)
+ :return: the path to the found kdestroy executable
"""
- return find_path(["/usr/bin", "/usr/kerberos/bin", "/usr/sbin"], "kdestroy")
\ No newline at end of file
+ return find_executable(search_directories, "kdestroy")
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ambari/blob/5fcfb6ab/ambari-common/src/main/python/resource_management/libraries/functions/get_kinit_path.py
----------------------------------------------------------------------
diff --git a/ambari-common/src/main/python/resource_management/libraries/functions/get_kinit_path.py b/ambari-common/src/main/python/resource_management/libraries/functions/get_kinit_path.py
index 7904a0f..23f1c9a 100644
--- a/ambari-common/src/main/python/resource_management/libraries/functions/get_kinit_path.py
+++ b/ambari-common/src/main/python/resource_management/libraries/functions/get_kinit_path.py
@@ -21,14 +21,14 @@ Ambari Agent
"""
__all__ = ["get_kinit_path"]
-from find_path import find_path
+from find_executable import find_executable
-def get_kinit_path():
+def get_kinit_path(search_directories=None):
"""
- Searches for the kinit executable using a default set of of paths to search:
- /usr/bin
- /usr/kerberos/bin
- /usr/sbin
+ Searches for the kinit executable using the specified search paths or a default set of of paths to search
+
+ @param search_directories: comma separated list or a list of (absolute paths to) directories to search (in order of preference)
+ :return: the path to the found kinit executable
"""
- return find_path(["/usr/bin", "/usr/kerberos/bin", "/usr/sbin"], "kinit")
\ No newline at end of file
+ return find_executable(search_directories, "kinit")
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ambari/blob/5fcfb6ab/ambari-common/src/main/python/resource_management/libraries/functions/get_klist_path.py
----------------------------------------------------------------------
diff --git a/ambari-common/src/main/python/resource_management/libraries/functions/get_klist_path.py b/ambari-common/src/main/python/resource_management/libraries/functions/get_klist_path.py
index cd8ca10..650177e 100644
--- a/ambari-common/src/main/python/resource_management/libraries/functions/get_klist_path.py
+++ b/ambari-common/src/main/python/resource_management/libraries/functions/get_klist_path.py
@@ -21,14 +21,14 @@ Ambari Agent
"""
__all__ = ["get_klist_path"]
-from find_path import find_path
+from find_executable import find_executable
-def get_klist_path():
+def get_klist_path(search_directories=None):
"""
- Searches for the klist executable using a default set of of paths to search:
- /usr/bin
- /usr/kerberos/bin
- /usr/sbin
+ Searches for the klist executable using the specified search paths or a default set of of paths to search
+
+ @param search_directories: comma separated list or a list of (absolute paths to) directories to search (in order of preference)
+ :return: the path to the found klist executable
"""
- return find_path(["/usr/bin", "/usr/kerberos/bin", "/usr/sbin"], "klist")
+ return find_executable(search_directories, "klist")
http://git-wip-us.apache.org/repos/asf/ambari/blob/5fcfb6ab/ambari-server/src/main/java/org/apache/ambari/server/serveraction/kerberos/KerberosOperationHandler.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/serveraction/kerberos/KerberosOperationHandler.java b/ambari-server/src/main/java/org/apache/ambari/server/serveraction/kerberos/KerberosOperationHandler.java
index d5384d2..ed31ccf 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/serveraction/kerberos/KerberosOperationHandler.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/serveraction/kerberos/KerberosOperationHandler.java
@@ -91,12 +91,22 @@ public abstract class KerberosOperationHandler {
public final static String KERBEROS_ENV_ADMIN_SERVER_HOST = "admin_server_host";
/**
+ * Kerberos-env configuration property name: executable_search_paths
+ */
+ public final static String KERBEROS_ENV_EXECUTABLE_SEARCH_PATHS = "executable_search_paths";
+
+ /**
* The set of available characters to use when generating a secure password
*/
private final static char[] SECURE_PASSWORD_CHARS =
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890?.!$%^*()-_+=~".toCharArray();
/**
+ * An array of String values declaring the default (ordered) list of path to search for executables
+ */
+ private static final String[] DEFAULT_EXECUTABLE_SEARCH_PATHS = {"/usr/bin", "/usr/kerberos/bin", "/usr/sbin", "/usr/lib/mit/bin", "/usr/lib/mit/sbin"};
+
+ /**
* A Map of MIT KDC Encryption types to EncryptionType values.
* <p/>
* See http://web.mit.edu/kerberos/krb5-devel/doc/admin/conf_files/kdc_conf.html#encryption-types
@@ -193,6 +203,13 @@ public abstract class KerberosOperationHandler {
private boolean open = false;
/**
+ * An array of String indicating an ordered list of filesystem paths to use to search for executables
+ * needed to perform Kerberos-related operations. For example, kadmin
+ */
+ private String[] executableSearchPaths = null;
+
+
+ /**
* Create a secure (random) password using a secure random number generator and a set of (reasonable)
* characters.
*
@@ -588,6 +605,62 @@ public abstract class KerberosOperationHandler {
);
}
+
+ /**
+ * Gets the ordered array of search paths used to find Kerberos-related executables.
+ *
+ * @return an array of String values indicating an order list of filesystem paths to search
+ */
+ public String[] getExecutableSearchPaths() {
+ return executableSearchPaths;
+ }
+
+ /**
+ * Sets the ordered array of search paths used to find Kerberos-related executables.
+ * <p/>
+ * If null, a default set of paths will be assumed when searching:
+ * <ul>
+ * <li>/usr/bin</li>
+ * <li>/usr/kerberos/bin</li>
+ * <li>/usr/sbin</li>
+ * <li>/usr/lib/mit/bin</li>
+ * <li>/usr/lib/mit/sbin</li>
+ * </ul>
+ *
+ * @param executableSearchPaths an array of String values indicating an ordered list of filesystem paths to search
+ */
+ public void setExecutableSearchPaths(String[] executableSearchPaths) {
+ this.executableSearchPaths = executableSearchPaths;
+ }
+
+ /**
+ * Sets the ordered array of search paths used to find Kerberos-related executables.
+ * <p/>
+ * If null, a default set of paths will be assumed when searching:
+ * <ul>
+ * <li>/usr/bin</li>
+ * <li>/usr/kerberos/bin</li>
+ * <li>/usr/sbin</li>
+ * </ul>
+ *
+ * @param delimitedExecutableSearchPaths a String containing a comma-delimited (ordered) list of filesystem paths to search
+ */
+ public void setExecutableSearchPaths(String delimitedExecutableSearchPaths) {
+ List<String> searchPaths = null;
+
+ if (delimitedExecutableSearchPaths != null) {
+ searchPaths = new ArrayList<String>();
+ for (String path : delimitedExecutableSearchPaths.split(",")) {
+ path = path.trim();
+ if (!path.isEmpty()) {
+ searchPaths.add(path);
+ }
+ }
+ }
+
+ setExecutableSearchPaths((searchPaths == null) ? null : searchPaths.toArray(new String[searchPaths.size()]));
+ }
+
/**
* Test this KerberosOperationHandler to see whether is was previously open or not
*
@@ -777,4 +850,34 @@ public abstract class KerberosOperationHandler {
return builder.toString();
}
}
+
+ /**
+ * Given the name of an executable, searches the configured executable search path for an executable
+ * file with that name.
+ *
+ * @param executable a String declaring the name of the executable to find within the search path
+ * @return the absolute path of the found execute or the name of the executable if not found
+ * within the search path
+ * @see #setExecutableSearchPaths(String)
+ * @see #setExecutableSearchPaths(String[])
+ */
+ protected String getExecutable(String executable) {
+ String[] searchPaths = getExecutableSearchPaths();
+ String executablePath = null;
+
+ if (searchPaths == null) {
+ searchPaths = DEFAULT_EXECUTABLE_SEARCH_PATHS;
+ }
+
+ for (String searchPath : searchPaths) {
+ File executableFile = new File(searchPath, executable);
+
+ if (executableFile.canExecute()) {
+ executablePath = executableFile.getAbsolutePath();
+ break;
+ }
+ }
+
+ return (executablePath == null) ? executable : executablePath;
+ }
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/5fcfb6ab/ambari-server/src/main/java/org/apache/ambari/server/serveraction/kerberos/MITKerberosOperationHandler.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/serveraction/kerberos/MITKerberosOperationHandler.java b/ambari-server/src/main/java/org/apache/ambari/server/serveraction/kerberos/MITKerberosOperationHandler.java
index 69b0292..cd74c22 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/serveraction/kerberos/MITKerberosOperationHandler.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/serveraction/kerberos/MITKerberosOperationHandler.java
@@ -18,8 +18,6 @@
package org.apache.ambari.server.serveraction.kerberos;
-import com.google.inject.Inject;
-import org.apache.ambari.server.configuration.Configuration;
import org.apache.ambari.server.utils.ShellCommandUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -51,12 +49,19 @@ public class MITKerberosOperationHandler extends KerberosOperationHandler {
private final static Logger LOG = LoggerFactory.getLogger(MITKerberosOperationHandler.class);
- @Inject
- private Configuration configuration;
-
private String adminServerHost = null;
/**
+ * A String containing the resolved path to the kdamin executable
+ */
+ private String executableKadmin = null;
+
+ /**
+ * A String containing the resolved path to the kdamin.local executable
+ */
+ private String executableKadminLocal = null;
+
+ /**
* Prepares and creates resources to be used by this KerberosOperationHandler
* <p/>
* It is expected that this KerberosOperationHandler will not be used before this call.
@@ -83,8 +88,13 @@ public class MITKerberosOperationHandler extends KerberosOperationHandler {
if (kerberosConfiguration != null) {
setKeyEncryptionTypes(translateEncryptionTypes(kerberosConfiguration.get(KERBEROS_ENV_ENCRYPTION_TYPES), "\\s+"));
setAdminServerHost(kerberosConfiguration.get(KERBEROS_ENV_ADMIN_SERVER_HOST));
+ setExecutableSearchPaths(kerberosConfiguration.get(KERBEROS_ENV_EXECUTABLE_SEARCH_PATHS));
}
+ // Pre-determine the paths to relevant Kerberos executables
+ executableKadmin = getExecutable("kadmin");
+ executableKadminLocal = getExecutable("kadmin.local");
+
setOpen(true);
}
@@ -92,6 +102,9 @@ public class MITKerberosOperationHandler extends KerberosOperationHandler {
public void close() throws KerberosOperationException {
// There is nothing to do here.
setOpen(false);
+
+ executableKadmin = null;
+ executableKadminLocal = null;
}
/**
@@ -234,18 +247,6 @@ public class MITKerberosOperationHandler extends KerberosOperationHandler {
}
/**
- * Initialize this MITKerberosOperationHandler with instances of objects that should normally
- * be injected.
- * <p/>
- * This should only be used for unit tests.
- *
- * @param configuration the Configuration to (manually) inject
- */
- public void init(Configuration configuration) {
- this.configuration = configuration;
- }
-
- /**
* Retrieves the current key number assigned to the identity identified by the specified principal
*
* @param principal a String declaring the principal to look up
@@ -326,24 +327,25 @@ public class MITKerberosOperationHandler extends KerberosOperationHandler {
? null
: administratorCredentials.getPrincipal();
- String pathToCommand = "";
-
- if (configuration.getServerOsFamily().equals("redhat5")) {
- pathToCommand = "/usr/kerberos/sbin/";
- }
-
if ((adminPrincipal == null) || adminPrincipal.isEmpty()) {
// Set the kdamin interface to be kadmin.local
- command.add(pathToCommand + "kadmin.local");
+ if((executableKadminLocal == null) || executableKadminLocal.isEmpty()) {
+ throw new KerberosOperationException("No path for kadmin.local is available - this KerberosOperationHandler may not have been opened.");
+ }
+
+ command.add(executableKadminLocal);
} else {
+ if((executableKadmin == null) || executableKadmin.isEmpty()) {
+ throw new KerberosOperationException("No path for kadmin is available - this KerberosOperationHandler may not have been opened.");
+ }
String adminPassword = administratorCredentials.getPassword();
String adminKeyTab = administratorCredentials.getKeytab();
// Set the kdamin interface to be kadmin
- command.add(pathToCommand + "kadmin");
+ command.add(executableKadmin);
// Add explicit KDC admin host, if available
- if(getAdminServerHost() != null) {
+ if (getAdminServerHost() != null) {
command.add("-s");
command.add(getAdminServerHost());
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/5fcfb6ab/ambari-server/src/main/resources/common-services/KERBEROS/1.10.3-10/configuration/kerberos-env.xml
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/KERBEROS/1.10.3-10/configuration/kerberos-env.xml b/ambari-server/src/main/resources/common-services/KERBEROS/1.10.3-10/configuration/kerberos-env.xml
index 31833cb..9c12b34 100644
--- a/ambari-server/src/main/resources/common-services/KERBEROS/1.10.3-10/configuration/kerberos-env.xml
+++ b/ambari-server/src/main/resources/common-services/KERBEROS/1.10.3-10/configuration/kerberos-env.xml
@@ -77,6 +77,13 @@
<value/>
</property>
+ <property>
+ <name>executable_search_paths</name>
+ <description>
+ A comma-delimited list of search paths to use to find Kerberos utilities like kadmin and kinit.
+ </description>
+ <value>/usr/bin, /usr/kerberos/bin, /usr/sbin, /usr/lib/mit/bin, /usr/lib/mit/sbin</value>
+ </property>
<property require-input="true">
<name>create_attributes_template</name>
http://git-wip-us.apache.org/repos/asf/ambari/blob/5fcfb6ab/ambari-server/src/test/java/org/apache/ambari/server/serveraction/kerberos/KerberosOperationHandlerTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/serveraction/kerberos/KerberosOperationHandlerTest.java b/ambari-server/src/test/java/org/apache/ambari/server/serveraction/kerberos/KerberosOperationHandlerTest.java
index 18d3bee..07094a7 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/serveraction/kerberos/KerberosOperationHandlerTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/serveraction/kerberos/KerberosOperationHandlerTest.java
@@ -340,6 +340,50 @@ public abstract class KerberosOperationHandlerTest extends EasyMockSupport {
handler.setAdministratorCredentials(credentials);
}
+ @Test
+ public void testSetExecutableSearchPaths() throws KerberosOperationException {
+ KerberosOperationHandler handler = createHandler();
+
+ handler.setExecutableSearchPaths((String)null);
+ Assert.assertNull(handler.getExecutableSearchPaths());
+
+ handler.setExecutableSearchPaths((String[])null);
+ Assert.assertNull(handler.getExecutableSearchPaths());
+
+ handler.setExecutableSearchPaths("");
+ Assert.assertNotNull(handler.getExecutableSearchPaths());
+ Assert.assertEquals(0, handler.getExecutableSearchPaths().length);
+
+ handler.setExecutableSearchPaths(new String[0]);
+ Assert.assertNotNull(handler.getExecutableSearchPaths());
+ Assert.assertEquals(0, handler.getExecutableSearchPaths().length);
+
+ handler.setExecutableSearchPaths(new String[]{""});
+ Assert.assertNotNull(handler.getExecutableSearchPaths());
+ Assert.assertEquals(1, handler.getExecutableSearchPaths().length);
+
+ handler.setExecutableSearchPaths("/path1, path2, path3/");
+ Assert.assertNotNull(handler.getExecutableSearchPaths());
+ Assert.assertEquals(3, handler.getExecutableSearchPaths().length);
+ Assert.assertEquals("/path1", handler.getExecutableSearchPaths()[0]);
+ Assert.assertEquals("path2", handler.getExecutableSearchPaths()[1]);
+ Assert.assertEquals("path3/", handler.getExecutableSearchPaths()[2]);
+
+ handler.setExecutableSearchPaths("/path1, path2, ,path3/");
+ Assert.assertNotNull(handler.getExecutableSearchPaths());
+ Assert.assertEquals(3, handler.getExecutableSearchPaths().length);
+ Assert.assertEquals("/path1", handler.getExecutableSearchPaths()[0]);
+ Assert.assertEquals("path2", handler.getExecutableSearchPaths()[1]);
+ Assert.assertEquals("path3/", handler.getExecutableSearchPaths()[2]);
+
+ handler.setExecutableSearchPaths(new String[]{"/path1", "path2", "path3/"});
+ Assert.assertNotNull(handler.getExecutableSearchPaths());
+ Assert.assertEquals(3, handler.getExecutableSearchPaths().length);
+ Assert.assertEquals("/path1", handler.getExecutableSearchPaths()[0]);
+ Assert.assertEquals("path2", handler.getExecutableSearchPaths()[1]);
+ Assert.assertEquals("path3/", handler.getExecutableSearchPaths()[2]);
+ }
+
private KerberosOperationHandler createHandler() throws KerberosOperationException {
KerberosOperationHandler handler = new KerberosOperationHandler() {
@@ -347,6 +391,7 @@ public abstract class KerberosOperationHandlerTest extends EasyMockSupport {
public void open(KerberosCredential administratorCredentials, String defaultRealm, Map<String, String> kerberosConfiguration) throws KerberosOperationException {
setAdministratorCredentials(administratorCredentials);
setDefaultRealm(defaultRealm);
+ setExecutableSearchPaths("/usr/bin, /usr/kerberos/bin, /usr/sbin");
}
@Override
http://git-wip-us.apache.org/repos/asf/ambari/blob/5fcfb6ab/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 0898282..1e05f8c 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
@@ -146,8 +146,6 @@ public class MITKerberosOperationHandlerTest extends KerberosOperationHandlerTes
.addMockedMethod(KerberosOperationHandler.class.getDeclaredMethod("executeCommand", String[].class))
.createNiceMock();
- setConfiguration(handler, "redhat6");
-
expect(handler.executeCommand(anyObject(String[].class)))
.andAnswer(new IAnswer<ShellCommandUtil.Result>() {
@Override
@@ -181,8 +179,6 @@ public class MITKerberosOperationHandlerTest extends KerberosOperationHandlerTes
.addMockedMethod(KerberosOperationHandler.class.getDeclaredMethod("executeCommand", String[].class))
.createNiceMock();
- setConfiguration(handler, "redhat6");
-
expect(handler.executeCommand(anyObject(String[].class)))
.andAnswer(new IAnswer<ShellCommandUtil.Result>() {
@Override
@@ -216,8 +212,6 @@ public class MITKerberosOperationHandlerTest extends KerberosOperationHandlerTes
.addMockedMethod(KerberosOperationHandler.class.getDeclaredMethod("executeCommand", String[].class))
.createNiceMock();
- setConfiguration(handler, "redhat6");
-
expect(handler.executeCommand(anyObject(String[].class)))
.andAnswer(new IAnswer<ShellCommandUtil.Result>() {
@Override
@@ -251,8 +245,6 @@ public class MITKerberosOperationHandlerTest extends KerberosOperationHandlerTes
.addMockedMethod(KerberosOperationHandler.class.getDeclaredMethod("executeCommand", String[].class))
.createNiceMock();
- setConfiguration(handler, "redhat6");
-
expect(handler.executeCommand(anyObject(String[].class)))
.andAnswer(new IAnswer<ShellCommandUtil.Result>() {
@Override
@@ -286,8 +278,6 @@ public class MITKerberosOperationHandlerTest extends KerberosOperationHandlerTes
.addMockedMethod(KerberosOperationHandler.class.getDeclaredMethod("executeCommand", String[].class))
.createNiceMock();
- setConfiguration(handler, "redhat6");
-
expect(handler.executeCommand(anyObject(String[].class)))
.andAnswer(new IAnswer<ShellCommandUtil.Result>() {
@Override
@@ -321,8 +311,6 @@ public class MITKerberosOperationHandlerTest extends KerberosOperationHandlerTes
.addMockedMethod(KerberosOperationHandler.class.getDeclaredMethod("executeCommand", String[].class))
.createNiceMock();
- setConfiguration(handler, "redhat6");
-
expect(handler.executeCommand(anyObject(String[].class)))
.andAnswer(new IAnswer<ShellCommandUtil.Result>() {
@Override
@@ -356,8 +344,6 @@ public class MITKerberosOperationHandlerTest extends KerberosOperationHandlerTes
.addMockedMethod(KerberosOperationHandler.class.getDeclaredMethod("executeCommand", String[].class))
.createNiceMock();
- setConfiguration(handler, "redhat6");
-
expect(handler.executeCommand(anyObject(String[].class)))
.andAnswer(new IAnswer<ShellCommandUtil.Result>() {
@Override
@@ -391,8 +377,6 @@ public class MITKerberosOperationHandlerTest extends KerberosOperationHandlerTes
.addMockedMethod(KerberosOperationHandler.class.getDeclaredMethod("executeCommand", String[].class))
.createNiceMock();
- setConfiguration(handler, "redhat6");
-
expect(handler.executeCommand(anyObject(String[].class)))
.andAnswer(new IAnswer<ShellCommandUtil.Result>() {
@Override
@@ -466,12 +450,4 @@ public class MITKerberosOperationHandlerTest extends KerberosOperationHandlerTes
handler.testAdministratorCredentials();
handler.close();
}
-
- private static void setConfiguration(MITKerberosOperationHandler handler, String osType) throws Exception {
- Configuration configuration = EasyMock.createNiceMock(Configuration.class);
- expect(configuration.getServerOsFamily()).andReturn("redhat6").anyTimes();
- replay(configuration);
-
- handler.init(configuration);
- }
}
\ No newline at end of file