forked from huashengdun/webssh
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2755a98
commit 4525f50
Showing
2 changed files
with
46 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters