diff options
author | Thomas Kluyver <takowl@gmail.com> | 2013-10-21 16:24:38 -0700 |
---|---|---|
committer | Thomas Kluyver <takowl@gmail.com> | 2013-10-21 16:24:38 -0700 |
commit | 1e830ff97c628fc20ed727dc3fd0a4d971d279d5 (patch) | |
tree | 6ff1fe23c059eba99d508b04dc50c174520ed959 /tests/fakessh | |
parent | 92f18089889c1c75b5ce4b31574e730bdb273530 (diff) | |
download | pexpect-git-1e830ff97c628fc20ed727dc3fd0a4d971d279d5.tar.gz |
Add test for pxssh module
Diffstat (limited to 'tests/fakessh')
-rwxr-xr-x | tests/fakessh/ssh | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/fakessh/ssh b/tests/fakessh/ssh new file mode 100755 index 0000000..318c18a --- /dev/null +++ b/tests/fakessh/ssh @@ -0,0 +1,23 @@ +#!/usr/bin/env python +import getpass +import sys +PY3 = (sys.version_info[0] >= 3) +if not PY3: + input = raw_input + +print("Mock SSH client for tests. Do not enter real security info.") + +pw = getpass.getpass('password:') +if pw != 's3cret': + print('Permission denied!') + sys.exit(1) + +prompt = "$" +while True: + cmd = input(prompt) + if cmd.startswith('PS1='): + prompt = eval(cmd[4:]).replace('\$', '$') + elif cmd == 'ping': + print('pong') + elif cmd in ('exit', 'logout'): + break
\ No newline at end of file |