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 cb5424a1662f9dbab4ba69cb239971831164f5a2
parent 96d9ae5b4d1654957f155e95c5bf1ad4ac65c734
Author: Sheng <webmaster0115@gmail.com>
Date:   Wed, 30 May 2018 17:35:51 +0800

Added dummy check_channel_window_change_request for testing

Diffstat:
Mtests/sshserver.py | 5+++++
Mtests/test_app.py | 13+++++++++++--
Mwebssh/handler.py | 2+-
3 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/tests/sshserver.py b/tests/sshserver.py @@ -76,6 +76,11 @@ class Server (paramiko.ServerInterface): pixelwidth, pixelheight, modes): return True + def check_channel_window_change_request(self, channel, width, height, + pixelwidth, pixelheight): + channel.send('resized') + return True + def run_ssh_server(port=2200, running=True): # now connect diff --git a/tests/test_app.py b/tests/test_app.py @@ -137,12 +137,15 @@ class TestApp(AsyncHTTPTestCase): msg = yield ws.read_message() self.assertIn(b'Welcome!', msg) - # message will be ignored silently + # messages below will be ignored silently yield ws.write_message('hello') yield ws.write_message('"hello"') yield ws.write_message('[hello]') yield ws.write_message(json.dumps({'resize': []})) yield ws.write_message(json.dumps({'resize': {}})) + yield ws.write_message(json.dumps({'resize': 'ab'})) + yield ws.write_message(json.dumps({'resize': ['a', 'b']})) + yield ws.write_message(json.dumps({'resize': {'a': 1, 'b': 2}})) yield ws.write_message(json.dumps({'resize': [100]})) yield ws.write_message(json.dumps({'resize': [100]*10})) yield ws.write_message(json.dumps({'resize': [-1, -1]})) @@ -152,7 +155,13 @@ class TestApp(AsyncHTTPTestCase): yield ws.write_message(json.dumps({'data': 1})) yield ws.write_message(json.dumps({'data': 2.1})) yield ws.write_message(json.dumps({'key-non-existed': 'hello'})) - yield ws.write_message(json.dumps({'resize': [79, 23], 'data': 'bye'})) + # end - those just for testing webssh websocket stablity + + yield ws.write_message(json.dumps({'resize': [79, 23]})) + msg = yield ws.read_message() + self.assertEqual(b'resized', msg) + + yield ws.write_message(json.dumps({'data': 'bye'})) msg = yield ws.read_message() self.assertEqual(b'bye', msg) ws.close() diff --git a/webssh/handler.py b/webssh/handler.py @@ -216,7 +216,7 @@ class WsockHandler(MixinHandler, tornado.websocket.WebSocketHandler): return resize = msg.get('resize') - if resize: + if resize and len(resize) == 2: try: worker.chan.resize_pty(*resize) except (TypeError, struct.error, paramiko.SSHException):