From 4fce2c648d03842b5c775f3109d5cd6602a5034c Mon Sep 17 00:00:00 2001 From: Red_M Date: Fri, 30 Mar 2018 12:25:05 +1000 Subject: Add testing for remote tunnels and passing the SSH authentication socket to the next connection. --- tests/test_pxssh.py | 34 ++++++++++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-) (limited to 'tests') diff --git a/tests/test_pxssh.py b/tests/test_pxssh.py index f68a1cc..f447840 100644 --- a/tests/test_pxssh.py +++ b/tests/test_pxssh.py @@ -56,9 +56,9 @@ class PxsshTestCase(SSHTestBase): pass else: assert False, 'should have raised exception, pxssh.ExceptionPxssh' - + def test_ssh_tunnel_string(self): - ssh = pxssh.pxssh(debug_tunnel_command=True) + ssh = pxssh.pxssh(debug_command_string=True) tunnels = { 'local': ['2424:localhost:22'],'remote': ['2525:localhost:22'], 'dynamic': [8888] } confirmation_strings = 0 @@ -68,8 +68,34 @@ class PxsshTestCase(SSHTestBase): if confirmation in string: confirmation_strings+=1 - if confirmation_strings!=3: - assert False, 'String generated from tunneling is potientally incorrect.' + if confirmation_strings!=len(confirmation_array): + assert False, 'String generated from tunneling is incorrect.' + + def test_remote_ssh_tunnel_string(self): + ssh = pxssh.pxssh(debug_command_string=True) + tunnels = { 'local': ['2424:localhost:22'],'remote': ['2525:localhost:22'], + 'dynamic': [8888] } + confirmation_strings = 0 + confirmation_array = ['-R \'2525:localhost:22\'','-L \'2424:localhost:22\'','-D \'8888\''] + string = ssh.login('server', 'me', password='s3cret', ssh_tunnels=tunnels, spawn_local_ssh=False) + for confirmation in confirmation_array: + if confirmation in string: + confirmation_strings+=1 + + if confirmation_strings!=len(confirmation_array): + assert False, 'String generated from remote tunneling is incorrect.' + + def test_force_ssh_agent_sock_string(self): + ssh = pxssh.pxssh(debug_command_string=True) + confirmation_strings = 0 + confirmation_array = [' -A'] + string = ssh.login('server', 'me', password='s3cret', ssh_key=True) + for confirmation in confirmation_array: + if confirmation in string: + confirmation_strings+=1 + + if confirmation_strings!=len(confirmation_array): + assert False, 'String generated from forcing the SSH agent sock is incorrect.' if __name__ == '__main__': -- cgit v1.2.1