Dulwich.io dulwich / 775696b
Merge change from PuttySSHVendor => PLinkSSHVendor. Jelmer Vernooń≥ 1 year, 5 months ago
4 changed file(s) with 22 addition(s) and 18 deletion(s). Raw diff Collapse all Expand all
135135 Antoine R. Dumont (@ardumont) <antoine.romain.dumont@gmail.com>
136136 Alistair Broomhead <alistair.broomhead@gmail.com>
137137 Marcel Schnirring <mschnirring@marcel-schnirring.de>
138 Adam Bradley <adam_bradley@brown.edu>
139 Filipp Frizzy <filipp.s.frizzy@gmail.com>
138140
139141 If you contributed but are missing from this list, please send me an e-mail.
1616
1717 * Fix repeat HTTP requests using the same smart HTTP client.
1818 (Jelmer Vernooń≥)
19
20 * New 'client.PLinkSSHVendor' for creating connections using PuTTY's plink.exe.
21 (Adam Bradley, Filipp Frizzy)
1922
2023 API CHANGES
2124
11281128 return SubprocessWrapper(proc)
11291129
11301130
1131 class PuttySSHVendor(SSHVendor):
1132 """SSH vendor that shells out to the local 'putty' command."""
1133
1131 class PLinkSSHVendor(SSHVendor):
1132 """SSH vendor that shells out to the local 'plink' command."""
11341133 def run_command(self, host, command, username=None, port=None,
11351134 password=None, key_filename=None):
11361135
11371136 if password and key_filename:
11381137 raise NotImplementedError(
11391138 "You can't set passphrase for ssh key "
1140 "with PuttySSHVendor, use ParamikoSSHVendor instead"
1139 "with PLinkSSHVendor, use ParamikoSSHVendor instead"
11411140 )
11421141
11431142 if sys.platform == 'win32':
1144 args = ['putty.exe', '-ssh']
1143 args = ['plink.exe', '-ssh']
11451144 else:
1146 args = ['putty', '-ssh']
1145 args = ['plink', '-ssh']
11471146
11481147 if password:
11491148 import warnings
11501149 warnings.warn(
1151 "Invoking Putty with a password exposes the password in the "
1150 "Invoking PLink with a password exposes the password in the "
11521151 "process list.")
11531152 args.extend(['-pw', str(password)])
11541153
5050 SendPackError,
5151 StrangeHostname,
5252 SubprocessSSHVendor,
53 PuttySSHVendor,
53 PLinkSSHVendor,
5454 UpdateRefsError,
5555 default_urllib3_manager,
5656 get_transport_and_path,
10401040 self.assertListEqual(expected, args[0])
10411041
10421042
1043 class PuttySSHVendorTests(TestCase):
1043 class PLinkSSHVendorTests(TestCase):
10441044
10451045 def setUp(self):
10461046 # Monkey Patch client subprocess popen
10511051 dulwich.client.subprocess.Popen = self._orig_popen
10521052
10531053 def test_run_command_dashes(self):
1054 vendor = PuttySSHVendor()
1054 vendor = PLinkSSHVendor()
10551055 self.assertRaises(StrangeHostname, vendor.run_command, '--weird-host',
10561056 'git-clone-url')
10571057
10581058 def test_run_command_password_and_privkey(self):
1059 vendor = PuttySSHVendor()
1059 vendor = PLinkSSHVendor()
10601060 self.assertRaises(NotImplementedError, vendor.run_command,
10611061 'host', 'git-clone-url',
10621062 password='12345', key_filename='/tmp/id_rsa')
10631063
10641064 def test_run_command_password(self):
10651065 if sys.platform == 'win32':
1066 binary = ['putty.exe', '-ssh']
1066 binary = ['plink.exe', '-ssh']
10671067 else:
1068 binary = ['putty', '-ssh']
1068 binary = ['plink', '-ssh']
10691069 expected = binary + ['-pw', '12345', 'host', 'git-clone-url']
10701070
1071 vendor = PuttySSHVendor()
1071 vendor = PLinkSSHVendor()
10721072
10731073 warnings.simplefilter("always", UserWarning)
10741074 self.addCleanup(warnings.resetwarnings)
10781078 command = vendor.run_command('host', 'git-clone-url', password='12345')
10791079
10801080 expected_warning = UserWarning(
1081 'Invoking Putty with a password exposes the password in the '
1081 'Invoking PLink with a password exposes the password in the '
10821082 'process list.')
10831083
10841084 for w in warnings_list:
10961096
10971097 def test_run_command_with_port_username_and_privkey(self):
10981098 if sys.platform == 'win32':
1099 binary = ['putty.exe', '-ssh']
1099 binary = ['plink.exe', '-ssh']
11001100 else:
1101 binary = ['putty', '-ssh']
1101 binary = ['plink', '-ssh']
11021102 expected = binary + [
11031103 '-P', '2200', '-i', '/tmp/id_rsa',
11041104 'user@host', 'git-clone-url']
11051105
1106 vendor = PuttySSHVendor()
1106 vendor = PLinkSSHVendor()
11071107 command = vendor.run_command(
11081108 'host', 'git-clone-url',
11091109 username='user', port='2200',