|
@@ -1058,9 +1058,38 @@ class PLinkSSHVendorTests(TestCase):
|
|
|
|
|
|
def test_run_command_password_and_privkey(self):
|
|
|
vendor = PLinkSSHVendor()
|
|
|
- self.assertRaises(NotImplementedError, vendor.run_command,
|
|
|
- 'host', 'git-clone-url',
|
|
|
- password='12345', key_filename='/tmp/id_rsa')
|
|
|
+
|
|
|
+ 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',
|
|
|
+ key_filename='/tmp/id_rsa')
|
|
|
+
|
|
|
+ expected_warning = UserWarning(
|
|
|
+ 'Invoking PLink 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
|
|
|
+
|
|
|
+ if sys.platform == 'win32':
|
|
|
+ binary = ['plink.exe', '-ssh']
|
|
|
+ else:
|
|
|
+ binary = ['plink', '-ssh']
|
|
|
+ expected = binary + [
|
|
|
+ '-pw', '12345', '-i', '/tmp/id_rsa', 'host', 'git-clone-url']
|
|
|
+ self.assertListEqual(expected, args[0])
|
|
|
|
|
|
def test_run_command_password(self):
|
|
|
if sys.platform == 'win32':
|