Browse Source

Merge change from PuttySSHVendor => PLinkSSHVendor.

Jelmer Vernooij 7 years ago
parent
commit
775696b494
4 changed files with 22 additions and 18 deletions
  1. 2 0
      AUTHORS
  2. 3 0
      NEWS
  3. 6 7
      dulwich/client.py
  4. 11 11
      dulwich/tests/test_client.py

+ 2 - 0
AUTHORS

@@ -136,5 +136,7 @@ Kenneth Lareau <kenneth.lareau@couchbase.com>
 Antoine R. Dumont (@ardumont) <antoine.romain.dumont@gmail.com>
 Alistair Broomhead <alistair.broomhead@gmail.com>
 Marcel Schnirring <mschnirring@marcel-schnirring.de>
+Adam Bradley <adam_bradley@brown.edu>
+Filipp Frizzy <filipp.s.frizzy@gmail.com>
 
 If you contributed but are missing from this list, please send me an e-mail.

+ 3 - 0
NEWS

@@ -18,6 +18,9 @@
   * Fix repeat HTTP requests using the same smart HTTP client.
     (Jelmer Vernooij)
 
+  * New 'client.PLinkSSHVendor' for creating connections using PuTTY's plink.exe.
+    (Adam Bradley, Filipp Frizzy)
+
  API CHANGES
 
   * Index.iterblobs has been renamed to Index.iterobjects.

+ 6 - 7
dulwich/client.py

@@ -1129,27 +1129,26 @@ class SubprocessSSHVendor(SSHVendor):
         return SubprocessWrapper(proc)
 
 
-class PuttySSHVendor(SSHVendor):
-    """SSH vendor that shells out to the local 'putty' command."""
-
+class PLinkSSHVendor(SSHVendor):
+    """SSH vendor that shells out to the local 'plink' command."""
     def run_command(self, host, command, username=None, port=None,
                     password=None, key_filename=None):
 
         if password and key_filename:
             raise NotImplementedError(
                 "You can't set passphrase for ssh key "
-                "with PuttySSHVendor, use ParamikoSSHVendor instead"
+                "with PLinkSSHVendor, use ParamikoSSHVendor instead"
             )
 
         if sys.platform == 'win32':
-            args = ['putty.exe', '-ssh']
+            args = ['plink.exe', '-ssh']
         else:
-            args = ['putty', '-ssh']
+            args = ['plink', '-ssh']
 
         if password:
             import warnings
             warnings.warn(
-                "Invoking Putty with a password exposes the password in the "
+                "Invoking PLink with a password exposes the password in the "
                 "process list.")
             args.extend(['-pw', str(password)])
 

+ 11 - 11
dulwich/tests/test_client.py

@@ -51,7 +51,7 @@ from dulwich.client import (
     SendPackError,
     StrangeHostname,
     SubprocessSSHVendor,
-    PuttySSHVendor,
+    PLinkSSHVendor,
     UpdateRefsError,
     default_urllib3_manager,
     get_transport_and_path,
@@ -1041,7 +1041,7 @@ class SubprocessSSHVendorTests(TestCase):
         self.assertListEqual(expected, args[0])
 
 
-class PuttySSHVendorTests(TestCase):
+class PLinkSSHVendorTests(TestCase):
 
     def setUp(self):
         # Monkey Patch client subprocess popen
@@ -1052,24 +1052,24 @@ class PuttySSHVendorTests(TestCase):
         dulwich.client.subprocess.Popen = self._orig_popen
 
     def test_run_command_dashes(self):
-        vendor = PuttySSHVendor()
+        vendor = PLinkSSHVendor()
         self.assertRaises(StrangeHostname, vendor.run_command, '--weird-host',
                           'git-clone-url')
 
     def test_run_command_password_and_privkey(self):
-        vendor = PuttySSHVendor()
+        vendor = PLinkSSHVendor()
         self.assertRaises(NotImplementedError, vendor.run_command,
                           'host', 'git-clone-url',
                           password='12345', key_filename='/tmp/id_rsa')
 
     def test_run_command_password(self):
         if sys.platform == 'win32':
-            binary = ['putty.exe', '-ssh']
+            binary = ['plink.exe', '-ssh']
         else:
-            binary = ['putty', '-ssh']
+            binary = ['plink', '-ssh']
         expected = binary + ['-pw', '12345', 'host', 'git-clone-url']
 
-        vendor = PuttySSHVendor()
+        vendor = PLinkSSHVendor()
 
         warnings.simplefilter("always", UserWarning)
         self.addCleanup(warnings.resetwarnings)
@@ -1079,7 +1079,7 @@ class PuttySSHVendorTests(TestCase):
         command = vendor.run_command('host', 'git-clone-url', password='12345')
 
         expected_warning = UserWarning(
-            'Invoking Putty with a password exposes the password in the '
+            'Invoking PLink with a password exposes the password in the '
             'process list.')
 
         for w in warnings_list:
@@ -1097,14 +1097,14 @@ class PuttySSHVendorTests(TestCase):
 
     def test_run_command_with_port_username_and_privkey(self):
         if sys.platform == 'win32':
-            binary = ['putty.exe', '-ssh']
+            binary = ['plink.exe', '-ssh']
         else:
-            binary = ['putty', '-ssh']
+            binary = ['plink', '-ssh']
         expected = binary + [
             '-P', '2200', '-i', '/tmp/id_rsa',
             'user@host', 'git-clone-url']
 
-        vendor = PuttySSHVendor()
+        vendor = PLinkSSHVendor()
         command = vendor.run_command(
             'host', 'git-clone-url',
             username='user', port='2200',