def test_run_command_password(self): if sys.platform == 'win32': binary = ['plink.exe', '-ssh'] else: binary = ['plink', '-ssh'] expected = binary + ['-pw', '12345', 'host', 'git-clone-url'] vendor = PLinkSSHVendor() 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='******') 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 self.assertListEqual(expected, args[0])
def test_run_command_password(self): if sys.platform == 'win32': binary = ['plink.exe', '-ssh'] else: binary = ['plink', '-ssh'] expected = binary + ['-pw', '12345', 'host', 'git-clone-url'] vendor = PLinkSSHVendor() 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='******') 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 self.assertListEqual(expected, args[0])
def test_run_command_with_port_username_and_privkey(self): if sys.platform == 'win32': binary = ['plink.exe', '-ssh'] else: binary = ['plink', '-ssh'] expected = binary + [ '-P', '2200', '-i', '/tmp/id_rsa', 'user@host', 'git-clone-url'] vendor = PLinkSSHVendor() command = vendor.run_command( 'host', 'git-clone-url', username='******', port='2200', key_filename='/tmp/id_rsa') args = command.proc.args self.assertListEqual(expected, args[0])
def test_run_command_dashes(self): vendor = PLinkSSHVendor() self.assertRaises(StrangeHostname, vendor.run_command, '--weird-host', 'git-clone-url')