Updated Branches:
  refs/heads/trunk 227560211 -> 5e3e1e005

AMBARI-2674. If the LDAP manager password is entered as a blank value on the 
first try, it will always be a blank. Unit Test. (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/5e3e1e00
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ambari/tree/5e3e1e00
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ambari/diff/5e3e1e00

Branch: refs/heads/trunk
Commit: 5e3e1e005a72c419d2f37b3797c94978b8c57d74
Parents: 07effbf
Author: Siddharth Wagle <[email protected]>
Authored: Wed Jul 17 10:15:59 2013 -0700
Committer: Siddharth Wagle <[email protected]>
Committed: Wed Jul 17 10:19:16 2013 -0700

----------------------------------------------------------------------
 .../src/test/python/TestAmbaryServer.py         | 34 +++++++++++++++++++-
 1 file changed, 33 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/5e3e1e00/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 5128f4d..c46419d 100644
--- a/ambari-server/src/test/python/TestAmbaryServer.py
+++ b/ambari-server/src/test/python/TestAmbaryServer.py
@@ -3462,7 +3462,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)

Reply via email to