summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorRed_M <pooatyou.com@gmail.com>2018-03-30 12:25:05 +1000
committerRed_M <pooatyou.com@gmail.com>2018-03-30 12:25:05 +1000
commit4fce2c648d03842b5c775f3109d5cd6602a5034c (patch)
treec471b3674892c6a407c7eb03573c5c3657f1c630 /tests
parent45108f0650c09680d0d0b7d7d3be4eeb86b8494d (diff)
downloadpexpect-git-4fce2c648d03842b5c775f3109d5cd6602a5034c.tar.gz
Add testing for remote tunnels and passing the SSH authentication socket to the next connection.
Diffstat (limited to 'tests')
-rw-r--r--tests/test_pxssh.py34
1 files changed, 30 insertions, 4 deletions
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__':