Rev 3423: John's review feedback. in http://bazaar.launchpad.net/%7Evila/bzr/203186-warn-pass-for-ssh-auth

Vincent Ladeuil v.ladeuil+lp at free.fr
Fri May 16 08:24:57 BST 2008


At http://bazaar.launchpad.net/%7Evila/bzr/203186-warn-pass-for-ssh-auth

------------------------------------------------------------
revno: 3423
revision-id: v.ladeuil+lp at free.fr-20080516072422-d6rfj3lw8rmldvfy
parent: v.ladeuil+lp at free.fr-20080515222045-0ewqm6gk6f8s58zv
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: 203186-warn-pass-for-ssh-auth
timestamp: Fri 2008-05-16 09:24:22 +0200
message:
  John's review feedback.
  
  * bzrlib/tests/test_config.py:
  (TestAuthenticationConfig.test_ssh_without_password_doesnt_emit_warning):
  Ensure that no warning is emitted if no password is defined.
  
  * bzrlib/config.py:
  (AuthenticationConfig.get_password): Check that there is a
  password defined before warning the user.
modified:
  bzrlib/config.py               config.py-20051011043216-070c74f4e9e338e8
  bzrlib/tests/test_config.py    testconfig.py-20051011041908-742d0c15d8d8c8eb
-------------- next part --------------
=== modified file 'bzrlib/config.py'
--- a/bzrlib/config.py	2008-05-15 22:20:45 +0000
+++ b/bzrlib/config.py	2008-05-16 07:24:22 +0000
@@ -1090,7 +1090,7 @@
         credentials = self.get_credentials(scheme, host, port, user, path)
         if credentials is not None:
             password = credentials['password']
-            if scheme is 'ssh':
+            if password is not None and scheme is 'ssh':
                 trace.warning('password ignored in section [%s],'
                               ' use an ssh agent instead'
                               % credentials['name'])

=== modified file 'bzrlib/tests/test_config.py'
--- a/bzrlib/tests/test_config.py	2008-05-15 22:20:45 +0000
+++ b/bzrlib/tests/test_config.py	2008-05-16 07:24:22 +0000
@@ -1434,6 +1434,29 @@
             self._get_log(keep_log_file=True),
             'password ignored in section \[ssh with password\]')
 
+    def test_ssh_without_password_doesnt_emit_warning(self):
+        conf = config.AuthenticationConfig(_file=StringIO(
+                """
+[ssh with password]
+scheme=ssh
+host=bar.org
+user=jim
+"""))
+        entered_password = 'typed-by-hand'
+        stdout = tests.StringIOWrapper()
+        ui.ui_factory = tests.TestUIFactory(stdin=entered_password + '\n',
+                                            stdout=stdout)
+
+        # Since the password defined in the authentication config is ignored,
+        # the user is prompted
+        self.assertEquals(entered_password,
+                          conf.get_password('ssh', 'bar.org', user='jim'))
+        # Not warning shoud be emitted since there is no password, we just
+        # provide the user.
+        self.assertNotContainsRe(
+            self._get_log(keep_log_file=True),
+            'password ignored in section \[ssh with password\]')
+
 
 # FIXME: Once we have a way to declare authentication to all test servers, we
 # can implement generic tests.



More information about the bazaar-commits mailing list