2018-10-23 14:56:18 +00:00
|
|
|
import unittest
|
|
|
|
|
|
|
|
from tornado.web import Application
|
2019-01-15 15:02:14 +00:00
|
|
|
from webssh import handler
|
2018-10-23 14:56:18 +00:00
|
|
|
from webssh.main import app_listen
|
|
|
|
|
|
|
|
|
|
|
|
class TestMain(unittest.TestCase):
|
|
|
|
|
|
|
|
def test_app_listen(self):
|
|
|
|
app = Application()
|
|
|
|
app.listen = lambda x, y, **kwargs: 1
|
|
|
|
|
2019-01-16 14:58:49 +00:00
|
|
|
handler.redirecting = None
|
2019-01-15 15:02:14 +00:00
|
|
|
server_settings = dict()
|
2018-10-23 14:56:18 +00:00
|
|
|
app_listen(app, 80, '127.0.0.1', server_settings)
|
2019-01-16 14:58:49 +00:00
|
|
|
self.assertFalse(handler.redirecting)
|
2018-10-23 14:56:18 +00:00
|
|
|
|
2019-01-16 14:58:49 +00:00
|
|
|
handler.redirecting = None
|
2019-01-15 15:02:14 +00:00
|
|
|
server_settings = dict(ssl_options='enabled')
|
|
|
|
app_listen(app, 80, '127.0.0.1', server_settings)
|
2019-01-16 14:58:49 +00:00
|
|
|
self.assertTrue(handler.redirecting)
|