You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by sw...@apache.org on 2013/07/17 19:25:39 UTC
git commit: AMBARI-2674. If the LDAP manager password is entered as a
blank value on the first try, it will always be a blank. (swagle)
Updated Branches:
refs/heads/branch-1.2.5 41dc31990 -> 189d284a2
AMBARI-2674. If the LDAP manager password is entered as a blank value on the first try, it will always be a blank. (swagle)
Project: http://git-wip-us.apache.org/repos/asf/incubator-ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ambari/commit/189d284a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ambari/tree/189d284a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ambari/diff/189d284a
Branch: refs/heads/branch-1.2.5
Commit: 189d284a28b64d1d4af050d1d2c6e95dbed19a43
Parents: 41dc319
Author: Siddharth Wagle <sw...@hortonworks.com>
Authored: Wed Jul 17 10:25:21 2013 -0700
Committer: Siddharth Wagle <sw...@hortonworks.com>
Committed: Wed Jul 17 10:25:21 2013 -0700
----------------------------------------------------------------------
ambari-server/src/main/python/ambari-server.py | 6 ++--
.../src/test/python/TestAmbaryServer.py | 34 +++++++++++++++++++-
2 files changed, 37 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/189d284a/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 c73c48c..53f8c46 100755
--- a/ambari-server/src/main/python/ambari-server.py
+++ b/ambari-server/src/main/python/ambari-server.py
@@ -994,14 +994,16 @@ def read_password(passwordDefault=PG_DEFAULT_PASSWORD,
if not password:
print 'Password cannot be blank.'
- read_password(passwordDefault, passwordPattern, passwordPrompt, passwordDescr)
+ return read_password(passwordDefault, passwordPattern, passwordPrompt,
+ passwordDescr)
if password != passwordDefault:
password1 = get_validated_string_input("Re-enter password: ",
passwordDefault, passwordPattern, passwordDescr, True)
if password != password1:
print "Passwords do not match"
- password = read_password(passwordDefault, passwordPattern, passwordPrompt, passwordDescr)
+ return read_password(passwordDefault, passwordPattern, passwordPrompt,
+ passwordDescr)
return password
http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/189d284a/ambari-server/src/test/python/TestAmbaryServer.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/python/TestAmbaryServer.py b/ambari-server/src/test/python/TestAmbaryServer.py
index 666fe50..1277280 100644
--- a/ambari-server/src/test/python/TestAmbaryServer.py
+++ b/ambari-server/src/test/python/TestAmbaryServer.py
@@ -3412,7 +3412,39 @@ MIIFHjCCAwYCCQDpHKOBI+Lt0zANBgkqhkiG9w0BAQUFADBRMQswCQYDVQQGEwJV
self.assertTrue(read_password_method.called)
sys.stdout = sys.__stdout__
-
+
+ @patch.object(ambari_server, 'get_validated_string_input')
+ def test_read_password(self, get_validated_string_input_method):
+ out = StringIO.StringIO()
+ sys.stdout = out
+
+ passwordDefault = ""
+ passwordPrompt = 'Enter Manager Password* : '
+ passwordPattern = ".*"
+ passwordDescr = "Invalid characters in password."
+
+ get_validated_string_input_method.side_effect = ['', 'aaa', 'aaa']
+ password = ambari_server.read_password(passwordDefault, passwordPattern,
+ passwordPrompt, passwordDescr)
+ self.assertTrue(3, get_validated_string_input_method.call_count)
+ self.assertEquals('aaa', password)
+
+ get_validated_string_input_method.reset_mock()
+ get_validated_string_input_method.side_effect = ['aaa', 'aaa']
+ password = ambari_server.read_password(passwordDefault, passwordPattern,
+ passwordPrompt, passwordDescr)
+ self.assertTrue(2, get_validated_string_input_method.call_count)
+ self.assertEquals('aaa', password)
+
+ get_validated_string_input_method.reset_mock()
+ get_validated_string_input_method.side_effect = ['aaa']
+ password = ambari_server.read_password('aaa', passwordPattern,
+ passwordPrompt, passwordDescr)
+ self.assertTrue(1, get_validated_string_input_method.call_count)
+ self.assertEquals('aaa', password)
+
+ sys.stdout = sys.__stdout__
+
def test_generate_random_string(self):
random_str_len = 100
str1 = ambari_server.generate_random_string(random_str_len)