You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by ao...@apache.org on 2014/05/07 16:41:19 UTC
git commit: AMBARI-5610. Usability: When setting up HTTPS for
ambari-server,
ambari didn't validate the path name and generate misleading error message
(aonishuk)
Repository: ambari
Updated Branches:
refs/heads/trunk 00cc0cf50 -> 4c2d80a17
AMBARI-5610. Usability: When setting up HTTPS for ambari-server, ambari didn't validate the path name and generate misleading error message (aonishuk)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/4c2d80a1
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/4c2d80a1
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/4c2d80a1
Branch: refs/heads/trunk
Commit: 4c2d80a1752e74c94ec87861b9ac5fcf4b922660
Parents: 00cc0cf
Author: Andrew Onishuk <ao...@hortonworks.com>
Authored: Wed May 7 17:40:52 2014 +0300
Committer: Andrew Onishuk <ao...@hortonworks.com>
Committed: Wed May 7 17:40:52 2014 +0300
----------------------------------------------------------------------
ambari-server/src/main/python/ambari-server.py | 2 +-
ambari-server/src/test/python/TestAmbariServer.py | 11 +++++++----
2 files changed, 8 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/4c2d80a1/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 ad2d11e..79c6fc1 100755
--- a/ambari-server/src/main/python/ambari-server.py
+++ b/ambari-server/src/main/python/ambari-server.py
@@ -3770,7 +3770,7 @@ def get_validated_filepath_input(prompt, description, default=None):
input = raw_input(prompt)
if not input == None:
input = input.strip()
- if not input == None and not "" == input and os.path.exists(input):
+ if not input == None and not "" == input and os.path.isfile(input):
return input
else:
print description
http://git-wip-us.apache.org/repos/asf/ambari/blob/4c2d80a1/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 f980309..3006a5c 100644
--- a/ambari-server/src/test/python/TestAmbariServer.py
+++ b/ambari-server/src/test/python/TestAmbariServer.py
@@ -1433,22 +1433,25 @@ class TestAmbariServer(TestCase):
@patch("__builtin__.open")
@patch.object(ambari_server, "run_os_command")
@patch("os.path.join")
- @patch.object(ambari_server, "get_validated_filepath_input")
+ @patch("os.path.isfile")
+ @patch('__builtin__.raw_input')
@patch.object(ambari_server, "get_validated_string_input")
@patch.object(ambari_server, "is_valid_cert_host")
@patch.object(ambari_server, "is_valid_cert_exp")
def test_import_cert_and_key(self, is_valid_cert_exp_mock, \
is_valid_cert_host_mock, \
get_validated_string_input_mock, \
- get_validated_filepath_input_mock, \
+ raw_input_mock, \
+ os_path_isfile_mock, \
os_path_join_mock, run_os_command_mock, \
open_mock, import_file_to_keystore_mock, \
set_file_permissions_mock, read_ambari_user_mock, copy_file_mock, \
remove_file_mock):
is_valid_cert_exp_mock.return_value = True
is_valid_cert_host_mock.return_value = True
+ os_path_isfile_mock.return_value = True
get_validated_string_input_mock.return_value = "password"
- get_validated_filepath_input_mock.side_effect = \
+ raw_input_mock.side_effect = \
["cert_file_path", "key_file_path"]
os_path_join_mock.side_effect = ["keystore_file_path", "keystore_file_path_tmp", \
"pass_file_path", "pass_file_path_tmp", \
@@ -1467,7 +1470,7 @@ class TestAmbariServer(TestCase):
" 'keystore_cert_key_file_path')]"
ambari_server.import_cert_and_key("key_dir")
- self.assertTrue(get_validated_filepath_input_mock.call_count == 2)
+ self.assertTrue(raw_input_mock.call_count == 2)
self.assertTrue(get_validated_string_input_mock.called)
self.assertEqual(os_path_join_mock.call_count, 8)
self.assertTrue(set_file_permissions_mock.call_count == 1)