コード例 #1
0
ファイル: test_ssh.py プロジェクト: filintod/pyremotelogin
    def test_ssh_terminal_connection_send_cmd_check_output_b2b(self):
        ssh = SshConnection(**conn_default)
        cmd = 'whoami'

        t0 = time.time()
        with ssh.open_terminal(connect_timeout=0.1) as t:
            whoami = t.send_cmd('mkdir testing').check_output('whoami')
            print(t.get_conversation_string())

        # check we got our expected files/folders
        self.assertEqual(whoami, 'learner')
コード例 #2
0
ファイル: test_ssh.py プロジェクト: filintod/pyremotelogin
 def test_ssh_terminal_sudo_connection(self):
     ssh = SshConnection('localhost',
                         port=2220,
                         username='******',
                         password='******')
     cmd = 'ls'
     expected = 'cumulus_demo\s+keystonerc_demo'
     with ssh.open_terminal(login_timeout=0.1) as t:
         ls = t.check_output(cmd)
         exp = t.send_cmd('sudo su -').expect_new_prompt()
         if exp.matched:
             print(t.check_output('cat /etc/ssh/sshd_config'))
コード例 #3
0
ファイル: test_ssh.py プロジェクト: filintod/pyremotelogin
    def test_ssh_terminal_connection(self):
        ssh = SshConnection(**conn_default)
        cmd = 'whoami'

        t0 = time.time()
        with ssh.open_terminal(connect_timeout=0.1) as t:
            print(time.time() - t0)
            ls = t.check_output(cmd)
            print(t.get_conversation_string())

        # check we got our expected files/folders
        self.assertEqual(ls, user['username'])

        # check data sent/received stored in self.data structure is correct
        conv = t.data.get_conversation_list()
コード例 #4
0
ファイル: test_ssh.py プロジェクト: filintod/pyremotelogin
 def test_ssh_tunnel_proxyjump(self):
     ssh = SshConnection(proxy_jump=SshConnection(
         proxy_jump=SshConnection(proxy_jump=SshConnection(**conn_default),
                                  host='127.0.0.1',
                                  **user),
         host='127.0.0.1',
         **user),
                         host='127.0.0.1',
                         **user)
     cmd = 'hostname'
     import time
     t0 = time.time()
     with ssh.open_terminal() as ssh:
         print('\n' + ssh.check_output(cmd))
     print(time.time() - t0)
コード例 #5
0
ファイル: test_ssh.py プロジェクト: filintod/pyremotelogin
    def test_ssh_timeout(self):
        ssh = SshConnection('localhost',
                            port=2220,
                            username='******',
                            password='******',
                            os='linux',
                            connect_timeout=0.2)
        cmd = 'tail -f /var/log/messages'
        import time

        t = time.time()
        with ssh.open_terminal() as term:
            t0 = time.time()
            print(t0 - t)
            try:
                ls = term.check_output(cmd, use_sudo=True, timeout=8)
                print(ls)
            except:
                pass
            self.assertEquals(8, int(time.time() - t0))
            e = term.send_ctrl_c().expect_prompt()
            self.assertTrue(e.matched)
            print(term.data.get_conversation_list())