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 4525f50b118a3ce7634d3db8bfdbb4d4cbe8f1e4
parent 2755a9871cc7be3ea4310ccfcac5faf639c6f0bc
Author: Sheng <webmaster0115@gmail.com>
Date:   Tue, 23 Oct 2018 22:56:18 +0800

Added test_main.py to tests

Diffstat:
Atests/test_main.py | 45+++++++++++++++++++++++++++++++++++++++++++++
Mwebssh/handler.py | 1+
2 files changed, 46 insertions(+), 0 deletions(-)

diff --git a/tests/test_main.py b/tests/test_main.py @@ -0,0 +1,45 @@ +import unittest + +from tornado.web import Application +from webssh.handler import open_to_public +from webssh.main import app_listen + + +class TestMain(unittest.TestCase): + + def test_app_listen(self): + app = Application() + app.listen = lambda x, y, **kwargs: 1 + open_to_public['https'] = None + open_to_public['http'] = None + + server_settings = dict(ssl_options=False) + app_listen(app, 80, '127.0.0.1', server_settings) + self.assertEqual(open_to_public['http'], False) + self.assertIsNone(open_to_public['https']) + open_to_public['http'] = None + + server_settings = dict(ssl_options=False) + app_listen(app, 80, '0.0.0.0', server_settings) + self.assertEqual(open_to_public['http'], True) + self.assertIsNone(open_to_public['https']) + open_to_public['http'] = None + + server_settings = dict(ssl_options=True) + app_listen(app, 443, '127.0.0.1', server_settings) + self.assertEqual(open_to_public['https'], False) + self.assertIsNone(open_to_public['http']) + open_to_public['https'] = None + + server_settings = dict(ssl_options=True) + app_listen(app, 443, '0.0.0.0', server_settings) + self.assertEqual(open_to_public['https'], True) + self.assertIsNone(open_to_public['http']) + open_to_public['https'] = None + + server_settings = dict(ssl_options=False) + app_listen(app, 80, '0.0.0.0', server_settings) + server_settings = dict(ssl_options=True) + app_listen(app, 443, '0.0.0.0', server_settings) + self.assertEqual(open_to_public['https'], True) + self.assertEqual(open_to_public['http'], True) diff --git a/webssh/handler.py b/webssh/handler.py @@ -43,6 +43,7 @@ open_to_public = { def config_open_to_public(address, server_type): status = True if is_name_open_to_public(address) else False + logging.debug('{} server open to public: {}'.format(server_type, status)) open_to_public[server_type] = status