Index: third_party/pexpect/tests/fakessh/ssh |
diff --git a/third_party/pexpect/tests/fakessh/ssh b/third_party/pexpect/tests/fakessh/ssh |
new file mode 100644 |
index 0000000000000000000000000000000000000000..28eedc4302b0bd3f8f2922c84a883e81a5dd9602 |
--- /dev/null |
+++ b/third_party/pexpect/tests/fakessh/ssh |
@@ -0,0 +1,29 @@ |
+#!/usr/bin/env python |
+from __future__ import print_function |
+ |
+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.startswith('ls'): |
+ print('file1.py', 'file2.html', sep='\t') |
+ elif cmd == 'echo $?': |
+ print(0) |
+ elif cmd in ('exit', 'logout'): |
+ break |