|
@@ -1033,79 +1033,6 @@ class SubprocessSSHVendorTests(TestCase):
|
|
|
self.assertListEqual(expected, args[0])
|
|
|
|
|
|
|
|
|
-class PuttySSHVendorTests(TestCase):
|
|
|
-
|
|
|
- def setUp(self):
|
|
|
- # Monkey Patch client subprocess popen
|
|
|
- self._orig_popen = dulwich.client.subprocess.Popen
|
|
|
- dulwich.client.subprocess.Popen = DummyPopen
|
|
|
-
|
|
|
- def tearDown(self):
|
|
|
- dulwich.client.subprocess.Popen = self._orig_popen
|
|
|
-
|
|
|
- def test_run_command_dashes(self):
|
|
|
- vendor = PuttySSHVendor()
|
|
|
- self.assertRaises(StrangeHostname, vendor.run_command, '--weird-host',
|
|
|
- 'git-clone-url')
|
|
|
-
|
|
|
- def test_run_command_password_and_privkey(self):
|
|
|
- vendor = PuttySSHVendor()
|
|
|
- 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']
|
|
|
- else:
|
|
|
- binary = ['putty', '-ssh']
|
|
|
- expected = binary + ['-pw', '12345', 'host', 'git-clone-url']
|
|
|
-
|
|
|
- vendor = PuttySSHVendor()
|
|
|
-
|
|
|
- warnings.simplefilter("always", UserWarning)
|
|
|
- self.addCleanup(warnings.resetwarnings)
|
|
|
- warnings_list, restore_warnings = setup_warning_catcher()
|
|
|
- self.addCleanup(restore_warnings)
|
|
|
-
|
|
|
- command = vendor.run_command('host', 'git-clone-url', password='12345')
|
|
|
-
|
|
|
- expected_warning = UserWarning(
|
|
|
- 'Invoking Putty with a password exposes the password in the '
|
|
|
- 'process list.')
|
|
|
-
|
|
|
- for w in warnings_list:
|
|
|
- if (type(w) == type(expected_warning) and
|
|
|
- w.args == expected_warning.args):
|
|
|
- break
|
|
|
- else:
|
|
|
- raise AssertionError(
|
|
|
- 'Expected warning %r not in %r' %
|
|
|
- (expected_warning, warnings_list))
|
|
|
-
|
|
|
- args = command.proc.args
|
|
|
-
|
|
|
- self.assertListEqual(expected, args[0])
|
|
|
-
|
|
|
- def test_run_command_with_port_username_and_privkey(self):
|
|
|
- if sys.platform == 'win32':
|
|
|
- binary = ['putty.exe', '-ssh']
|
|
|
- else:
|
|
|
- binary = ['putty', '-ssh']
|
|
|
- expected = binary + [
|
|
|
- '-P', '2200', '-i', '/tmp/id_rsa',
|
|
|
- 'user@host', 'git-clone-url']
|
|
|
-
|
|
|
- vendor = PuttySSHVendor()
|
|
|
- command = vendor.run_command(
|
|
|
- 'host', 'git-clone-url',
|
|
|
- username='user', port='2200',
|
|
|
- key_filename='/tmp/id_rsa')
|
|
|
-
|
|
|
- args = command.proc.args
|
|
|
-
|
|
|
- self.assertListEqual(expected, args[0])
|
|
|
-
|
|
|
class PLinkSSHVendorTests(TestCase):
|
|
|
|
|
|
def setUp(self):
|