|
|
@ -1,5 +1,4 @@
|
|
|
|
import io
|
|
|
|
import io
|
|
|
|
import random
|
|
|
|
|
|
|
|
import ssl
|
|
|
|
import ssl
|
|
|
|
import sys
|
|
|
|
import sys
|
|
|
|
import os.path
|
|
|
|
import os.path
|
|
|
@ -8,7 +7,6 @@ import paramiko
|
|
|
|
import tornado.options as options
|
|
|
|
import tornado.options as options
|
|
|
|
|
|
|
|
|
|
|
|
from tests.utils import make_tests_data_path
|
|
|
|
from tests.utils import make_tests_data_path
|
|
|
|
from webssh import handler
|
|
|
|
|
|
|
|
from webssh.policy import load_host_keys
|
|
|
|
from webssh.policy import load_host_keys
|
|
|
|
from webssh.settings import (
|
|
|
|
from webssh.settings import (
|
|
|
|
get_host_keys_settings, get_policy_setting, base_dir, print_version,
|
|
|
|
get_host_keys_settings, get_policy_setting, base_dir, print_version,
|
|
|
@ -141,39 +139,22 @@ class TestSettings(unittest.TestCase):
|
|
|
|
get_trusted_downstream(options), tdstream
|
|
|
|
get_trusted_downstream(options), tdstream
|
|
|
|
|
|
|
|
|
|
|
|
def test_detect_is_open_to_public(self):
|
|
|
|
def test_detect_is_open_to_public(self):
|
|
|
|
options.fbidhttp = random.choice([True, False])
|
|
|
|
options.fbidhttp = True
|
|
|
|
options.address = 'localhost'
|
|
|
|
options.address = '127.0.0.1'
|
|
|
|
detect_is_open_to_public(options)
|
|
|
|
detect_is_open_to_public(options)
|
|
|
|
self.assertFalse(handler.is_open_to_public)
|
|
|
|
self.assertFalse(options.fbidhttp)
|
|
|
|
self.assertEqual(handler.forbid_public_http, options.fbidhttp)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
options.fbidhttp = random.choice([True, False])
|
|
|
|
|
|
|
|
options.fbidhttp = False
|
|
|
|
options.fbidhttp = False
|
|
|
|
options.address = '127.0.0.1'
|
|
|
|
options.address = '127.0.0.1'
|
|
|
|
detect_is_open_to_public(options)
|
|
|
|
detect_is_open_to_public(options)
|
|
|
|
self.assertFalse(handler.is_open_to_public)
|
|
|
|
self.assertFalse(options.fbidhttp)
|
|
|
|
self.assertEqual(handler.forbid_public_http, options.fbidhttp)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
options.fbidhttp = random.choice([True, False])
|
|
|
|
|
|
|
|
options.address = '192.168.1.1'
|
|
|
|
|
|
|
|
detect_is_open_to_public(options)
|
|
|
|
|
|
|
|
self.assertFalse(handler.is_open_to_public)
|
|
|
|
|
|
|
|
self.assertEqual(handler.forbid_public_http, options.fbidhttp)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
options.fbidhttp = random.choice([True, False])
|
|
|
|
options.fbidhttp = False
|
|
|
|
options.address = ''
|
|
|
|
|
|
|
|
detect_is_open_to_public(options)
|
|
|
|
|
|
|
|
self.assertTrue(handler.is_open_to_public)
|
|
|
|
|
|
|
|
self.assertEqual(handler.forbid_public_http, options.fbidhttp)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
options.fbidhttp = random.choice([True, False])
|
|
|
|
|
|
|
|
options.address = '0.0.0.0'
|
|
|
|
options.address = '0.0.0.0'
|
|
|
|
detect_is_open_to_public(options)
|
|
|
|
detect_is_open_to_public(options)
|
|
|
|
self.assertTrue(handler.is_open_to_public)
|
|
|
|
self.assertFalse(options.fbidhttp)
|
|
|
|
self.assertEqual(handler.forbid_public_http, options.fbidhttp)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
options.fbidhttp = random.choice([True, False])
|
|
|
|
options.fbidhttp = True
|
|
|
|
options.address = '::'
|
|
|
|
options.address = '0.0.0.0'
|
|
|
|
detect_is_open_to_public(options)
|
|
|
|
detect_is_open_to_public(options)
|
|
|
|
self.assertTrue(handler.is_open_to_public)
|
|
|
|
self.assertTrue(options.fbidhttp)
|
|
|
|
self.assertEqual(handler.forbid_public_http, options.fbidhttp)
|
|
|
|
|
|
|
|