Added dummy check_channel_window_change_request for testing

pull/12/merge
Sheng 2018-05-30 17:35:51 +08:00
parent 96d9ae5b4d
commit cb5424a166
3 changed files with 17 additions and 3 deletions

View File

@ -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

View File

@ -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()

View File

@ -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):