Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(245)

Unified Diff: third_party/pexpect/tests/test_pxssh.py

Issue 1398903002: Add third_party/pexpect (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@end-to-end-test
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/pexpect/tests/test_popen_spawn.py ('k') | third_party/pexpect/tests/test_replwrap.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/pexpect/tests/test_pxssh.py
diff --git a/third_party/pexpect/tests/test_pxssh.py b/third_party/pexpect/tests/test_pxssh.py
new file mode 100644
index 0000000000000000000000000000000000000000..0ff092cdc36761504236eaa21598595310954124
--- /dev/null
+++ b/third_party/pexpect/tests/test_pxssh.py
@@ -0,0 +1,53 @@
+#!/usr/bin/env python
+import os
+
+import unittest
+
+from pexpect import pxssh
+
+class SSHTestBase(unittest.TestCase):
+ def setUp(self):
+ self.orig_path = os.environ.get('PATH')
+ fakessh_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), 'fakessh'))
+ os.environ['PATH'] = fakessh_dir + \
+ ((os.pathsep + self.orig_path) if self.orig_path else '')
+
+ def tearDown(self):
+ if self.orig_path:
+ os.environ['PATH'] = self.orig_path
+ else:
+ del os.environ['PATH']
+
+class PxsshTestCase(SSHTestBase):
+ def test_fake_ssh(self):
+ ssh = pxssh.pxssh()
+ #ssh.logfile_read = sys.stdout # DEBUG
+ ssh.login('server', 'me', password='s3cret')
+ ssh.sendline('ping')
+ ssh.expect('pong', timeout=10)
+ assert ssh.prompt(timeout=10)
+ ssh.logout()
+
+ def test_wrong_pw(self):
+ ssh = pxssh.pxssh()
+ try:
+ ssh.login('server', 'me', password='wr0ng')
+ except pxssh.ExceptionPxssh:
+ pass
+ else:
+ assert False, 'Password should have been refused'
+
+ def test_failed_set_unique_prompt(self):
+ ssh = pxssh.pxssh()
+ ssh.set_unique_prompt = lambda: False
+ try:
+ ssh.login('server', 'me', password='s3cret',
+ auto_prompt_reset=True)
+ except pxssh.ExceptionPxssh:
+ pass
+ else:
+ assert False, 'should have raised exception, pxssh.ExceptionPxssh'
+
+
+if __name__ == '__main__':
+ unittest.main()
« no previous file with comments | « third_party/pexpect/tests/test_popen_spawn.py ('k') | third_party/pexpect/tests/test_replwrap.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698