def test_execute_command(self, settings): ssh._call_paramiko_sshclient = MockSSHClient # pylint:disable=W0212 settings.server.hostname = 'example.com' settings.server.ssh_username = '******' settings.server.ssh_key = None settings.server.ssh_password = '******' with ssh.get_connection() as connection: # pylint:disable=W0212 ret = ssh.execute_command('ls -la', connection) self.assertEquals(ret.stdout, [u'ls -la']) self.assertIsInstance(ret, ssh.SSHCommandResult)
def test_execute_command(self, settings): ssh._call_paramiko_sshclient = MockSSHClient settings.server.hostname = 'example.com' settings.server.ssh_username = '******' settings.server.ssh_key = None settings.server.ssh_password = '******' settings.server.ssh_client.command_timeout = 300 settings.server.ssh_client.connection_timeout = 10 with ssh.get_connection() as connection: ret = ssh.execute_command('ls -la', connection) assert ret.stdout == ['ls -la'] assert isinstance(ret, ssh.SSHCommandResult)
def test_execute_command_plain_output(self, settings): ssh._call_paramiko_sshclient = MockSSHClient # pylint:disable=W0212 settings.server.hostname = 'example.com' settings.server.ssh_username = '******' settings.server.ssh_key = None settings.server.ssh_password = '******' settings.ssh_client.command_timeout = 300 settings.ssh_client.connection_timeout = 10 with ssh.get_connection() as connection: # pylint:disable=W0212 ret = ssh.execute_command( 'ls -la', connection, output_format='plain') self.assertEquals(ret.stdout, u'ls -la') self.assertIsInstance(ret, ssh.SSHCommandResult)
def test_execute_command_plain_output(self, settings): ssh._call_paramiko_sshclient = MockSSHClient # pylint:disable=W0212 settings.server.hostname = 'example.com' settings.server.ssh_username = '******' settings.server.ssh_key = None settings.server.ssh_password = '******' settings.ssh_client.command_timeout = 300 settings.ssh_client.connection_timeout = 10 with ssh.get_connection() as connection: # pylint:disable=W0212 ret = ssh.execute_command('ls -la', connection, output_format='plain') self.assertEqual(ret.stdout, u'ls -la') self.assertIsInstance(ret, ssh.SSHCommandResult)