You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by ds...@apache.org on 2013/10/30 13:31:08 UTC
git commit: AMBARI-3620. Ambari server setup-security kerberos jaas
configuration accepts directory path as keytab path (dsen)
Updated Branches:
refs/heads/branch-1.4.2 71173a313 -> 1ea2ea7bc
AMBARI-3620. Ambari server setup-security kerberos jaas configuration accepts directory path as keytab path (dsen)
Project: http://git-wip-us.apache.org/repos/asf/incubator-ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ambari/commit/1ea2ea7b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ambari/tree/1ea2ea7b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ambari/diff/1ea2ea7b
Branch: refs/heads/branch-1.4.2
Commit: 1ea2ea7bce52a0b9bcb8bc5211fb107b5b50d854
Parents: 71173a3
Author: Dmitry Sen <ds...@hortonworks.com>
Authored: Wed Oct 30 14:30:55 2013 +0200
Committer: Dmitry Sen <ds...@hortonworks.com>
Committed: Wed Oct 30 14:30:55 2013 +0200
----------------------------------------------------------------------
ambari-server/src/main/python/ambari-server.py | 2 +-
.../src/test/python/TestAmbariServer.py | 33 ++++++++++++++++++++
2 files changed, 34 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/1ea2ea7b/ambari-server/src/main/python/ambari-server.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/python/ambari-server.py b/ambari-server/src/main/python/ambari-server.py
index 325a405..1bc0569 100755
--- a/ambari-server/src/main/python/ambari-server.py
+++ b/ambari-server/src/main/python/ambari-server.py
@@ -3654,7 +3654,7 @@ def get_fqdn():
def is_valid_filepath(filepath):
- if not filepath or not os.path.exists(filepath):
+ if not filepath or not os.path.exists(filepath) or os.path.isdir(filepath):
print 'Invalid path, please provide the absolute file path.'
return False
else:
http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/1ea2ea7b/ambari-server/src/test/python/TestAmbariServer.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/python/TestAmbariServer.py b/ambari-server/src/test/python/TestAmbariServer.py
index 9c8a764..ed67e02 100644
--- a/ambari-server/src/test/python/TestAmbariServer.py
+++ b/ambari-server/src/test/python/TestAmbariServer.py
@@ -4255,3 +4255,36 @@ MIIFHjCCAwYCCQDpHKOBI+Lt0zANBgkqhkiG9w0BAQUFADBRMQswCQYDVQQGEwJV
del os.environ[ambari_server.AMBARI_CONF_VAR]
os.remove(prop_file)
+
+
+ def test_is_valid_filepath(self):
+ temp_dir = tempfile.gettempdir()
+ temp_file = tempfile.NamedTemporaryFile(mode='r')
+
+ # Correct path to an existing file
+ self.assertTrue(temp_file)
+ # Correct path to an existing directory
+ self.assertFalse(ambari_server.is_valid_filepath(temp_dir), \
+ 'is_valid_filepath(path) should return False if path is a directory')
+ # Incorrect path
+ self.assertFalse(ambari_server.is_valid_filepath(''))
+
+ @patch.object(ambari_server, "search_file")
+ @patch.object(ambari_server, "get_validated_string_input")
+ def test_setup_ambari_krb5_jaas(self, get_validated_string_input_mock,
+ search_file_mock):
+ search_file_mock.return_value = ''
+
+ # Should raise exception if jaas_conf_file isn't an existing file
+ self.assertRaises(NonFatalException, ambari_server.setup_ambari_krb5_jaas)
+
+ temp_file = tempfile.NamedTemporaryFile(mode='r')
+ search_file_mock.return_value = temp_file.name
+ get_validated_string_input_mock.side_effect = ['adm@EXAMPLE.COM', temp_file]
+
+ # setup_ambari_krb5_jaas() should return None if everything is OK
+ self.assertIsNone(ambari_server.setup_ambari_krb5_jaas())
+ self.assertTrue(get_validated_string_input_mock.called)
+ self.assertEqual(get_validated_string_input_mock.call_count, 2)
+
+