webssh

Web based ssh client https://github.com/huashengdun/webssh webssh.huashengdun.org/
git clone http://git.hanabi.in/repos/webssh.git
Log | Files | Refs | README | LICENSE

commit 330145484d6d3eed2783154e337917bd89aa7140
parent de0a903de808de232488a102bd76cebc09b7182b
Author: Sheng <webmaster0115@gmail.com>
Date:   Fri, 27 Apr 2018 14:34:06 +0800

Updated test_app.py and sshserver.py

Diffstat:
Mtests/sshserver.py | 8++++++--
Mtests/test_app.py | 22+++++++++++++++++++++-
2 files changed, 27 insertions(+), 3 deletions(-)

diff --git a/tests/sshserver.py b/tests/sshserver.py @@ -55,7 +55,7 @@ class Server (paramiko.ServerInterface): return paramiko.OPEN_FAILED_ADMINISTRATIVELY_PROHIBITED def check_auth_password(self, username, password): - if (username == 'robey') and (password == 'foo'): + if (username in ['robey', 'bar']) and (password == 'foo'): return paramiko.AUTH_SUCCESSFUL return paramiko.AUTH_FAILED @@ -104,7 +104,8 @@ def run_ssh_server(port=2200, running=True): print('*** No channel.') continue - print('Authenticated!') + username = t.get_username() + print('{} Authenticated!'.format(username)) server.event.wait(10) if not server.event.is_set(): @@ -112,6 +113,9 @@ def run_ssh_server(port=2200, running=True): continue chan.send('\r\n\r\nWelcome!\r\n\r\n') + if username == 'bar': + print(chan.recv(1024)) + chan.close() try: sock.close() diff --git a/tests/test_app.py b/tests/test_app.py @@ -102,7 +102,7 @@ class TestApp(AsyncHTTPTestCase): ws.close() @tornado.testing.gen_test - def test_app_with_correct_credentials_welcome(self): + def test_app_with_correct_credentials_user_robey(self): url = self.get_url('/') client = self.get_http_client() response = yield client.fetch(url) @@ -118,3 +118,23 @@ class TestApp(AsyncHTTPTestCase): msg = yield ws.read_message() self.assertIn('Welcome!', msg) ws.close() + + @tornado.testing.gen_test + def test_app_with_correct_credentials_user_bar(self): + url = self.get_url('/') + client = self.get_http_client() + response = yield client.fetch(url) + self.assertEqual(response.code, 200) + + body = self.body.replace('robey', 'bar') + response = yield client.fetch(url, method="POST", body=body) + worker_id = json.loads(response.body.decode('utf-8'))['id'] + self.assertIsNotNone(worker_id) + + url = url.replace('http', 'ws') + ws_url = url + 'ws?id=' + worker_id + ws = yield tornado.websocket.websocket_connect(ws_url) + msg = yield ws.read_message() + self.assertIn('Welcome!', msg) + yield ws.write_message('bye') + ws.close()