Commit 499f3b6d by Sheng

Lowercase all option names

parent 12f4c0d0
...@@ -43,9 +43,9 @@ class TestAppBasic(AsyncHTTPTestCase): ...@@ -43,9 +43,9 @@ class TestAppBasic(AsyncHTTPTestCase):
loop = self.io_loop loop = self.io_loop
options.debug = False options.debug = False
options.policy = random.choice(['warning', 'autoadd']) options.policy = random.choice(['warning', 'autoadd'])
options.hostFile = '' options.hostfile = ''
options.sysHostFile = '' options.syshostfile = ''
options.proxies = '' options.tdstream = ''
app = make_app(make_handlers(loop, options), get_app_settings(options)) app = make_app(make_handlers(loop, options), get_app_settings(options))
return app return app
...@@ -442,9 +442,9 @@ class OtherTestBase(AsyncHTTPTestCase): ...@@ -442,9 +442,9 @@ class OtherTestBase(AsyncHTTPTestCase):
headers = {'Cookie': '_xsrf=yummy'} headers = {'Cookie': '_xsrf=yummy'}
debug = False debug = False
policy = None policy = None
hostFile = '' hostfile = ''
sysHostFile = '' syshostfile = ''
proxies = '' tdstream = ''
body = { body = {
'hostname': '127.0.0.1', 'hostname': '127.0.0.1',
'port': '', 'port': '',
...@@ -458,9 +458,9 @@ class OtherTestBase(AsyncHTTPTestCase): ...@@ -458,9 +458,9 @@ class OtherTestBase(AsyncHTTPTestCase):
loop = self.io_loop loop = self.io_loop
options.debug = self.debug options.debug = self.debug
options.policy = self.policy if self.policy else random.choice(['warning', 'autoadd']) # noqa options.policy = self.policy if self.policy else random.choice(['warning', 'autoadd']) # noqa
options.hostFile = self.hostFile options.hostfile = self.hostfile
options.sysHostFile = self.sysHostFile options.syshostfile = self.syshostfile
options.proxies = self.proxies options.tdstream = self.tdstream
app = make_app(make_handlers(loop, options), get_app_settings(options)) app = make_app(make_handlers(loop, options), get_app_settings(options))
return app return app
...@@ -542,7 +542,7 @@ class TestAppMiscell(OtherTestBase): ...@@ -542,7 +542,7 @@ class TestAppMiscell(OtherTestBase):
class TestAppWithRejectPolicy(OtherTestBase): class TestAppWithRejectPolicy(OtherTestBase):
policy = 'reject' policy = 'reject'
hostFile = make_tests_data_path('known_hosts_example') hostfile = make_tests_data_path('known_hosts_example')
@tornado.testing.gen_test @tornado.testing.gen_test
def test_app_with_hostname_not_in_hostkeys(self): def test_app_with_hostname_not_in_hostkeys(self):
......
...@@ -32,8 +32,8 @@ class TestSettings(unittest.TestCase): ...@@ -32,8 +32,8 @@ class TestSettings(unittest.TestCase):
sys.stdout = sys_stdout sys.stdout = sys_stdout
def test_get_host_keys_settings(self): def test_get_host_keys_settings(self):
options.hostFile = '' options.hostfile = ''
options.sysHostFile = '' options.syshostfile = ''
dic = get_host_keys_settings(options) dic = get_host_keys_settings(options)
filename = os.path.join(base_dir, 'known_hosts') filename = os.path.join(base_dir, 'known_hosts')
...@@ -44,33 +44,33 @@ class TestSettings(unittest.TestCase): ...@@ -44,33 +44,33 @@ class TestSettings(unittest.TestCase):
load_host_keys(os.path.expanduser('~/.ssh/known_hosts')) load_host_keys(os.path.expanduser('~/.ssh/known_hosts'))
) )
options.hostFile = make_tests_data_path('known_hosts_example') options.hostfile = make_tests_data_path('known_hosts_example')
options.sysHostFile = make_tests_data_path('known_hosts_example2') options.syshostfile = make_tests_data_path('known_hosts_example2')
dic2 = get_host_keys_settings(options) dic2 = get_host_keys_settings(options)
self.assertEqual(dic2['host_keys'], load_host_keys(options.hostFile)) self.assertEqual(dic2['host_keys'], load_host_keys(options.hostfile))
self.assertEqual(dic2['host_keys_filename'], options.hostFile) self.assertEqual(dic2['host_keys_filename'], options.hostfile)
self.assertEqual(dic2['system_host_keys'], self.assertEqual(dic2['system_host_keys'],
load_host_keys(options.sysHostFile)) load_host_keys(options.syshostfile))
def test_get_policy_setting(self): def test_get_policy_setting(self):
options.policy = 'warning' options.policy = 'warning'
options.hostFile = '' options.hostfile = ''
options.sysHostFile = '' options.syshostfile = ''
settings = get_host_keys_settings(options) settings = get_host_keys_settings(options)
instance = get_policy_setting(options, settings) instance = get_policy_setting(options, settings)
self.assertIsInstance(instance, paramiko.client.WarningPolicy) self.assertIsInstance(instance, paramiko.client.WarningPolicy)
options.policy = 'autoadd' options.policy = 'autoadd'
options.hostFile = '' options.hostfile = ''
options.sysHostFile = '' options.syshostfile = ''
settings = get_host_keys_settings(options) settings = get_host_keys_settings(options)
instance = get_policy_setting(options, settings) instance = get_policy_setting(options, settings)
self.assertIsInstance(instance, paramiko.client.AutoAddPolicy) self.assertIsInstance(instance, paramiko.client.AutoAddPolicy)
os.unlink(settings['host_keys_filename']) os.unlink(settings['host_keys_filename'])
options.policy = 'reject' options.policy = 'reject'
options.hostFile = '' options.hostfile = ''
options.sysHostFile = '' options.syshostfile = ''
settings = get_host_keys_settings(options) settings = get_host_keys_settings(options)
try: try:
instance = get_policy_setting(options, settings) instance = get_policy_setting(options, settings)
...@@ -122,18 +122,18 @@ class TestSettings(unittest.TestCase): ...@@ -122,18 +122,18 @@ class TestSettings(unittest.TestCase):
self.assertIsNotNone(ssl_ctx) self.assertIsNotNone(ssl_ctx)
def test_get_trusted_downstream(self): def test_get_trusted_downstream(self):
options.proxies = '' options.tdstream = ''
proxies = set() tdstream = set()
self.assertEqual(get_trusted_downstream(options), proxies) self.assertEqual(get_trusted_downstream(options), tdstream)
options.proxies = '1.1.1.1, 2.2.2.2' options.tdstream = '1.1.1.1, 2.2.2.2'
proxies = set(['1.1.1.1', '2.2.2.2']) tdstream = set(['1.1.1.1', '2.2.2.2'])
self.assertEqual(get_trusted_downstream(options), proxies) self.assertEqual(get_trusted_downstream(options), tdstream)
options.proxies = '1.1.1.1, 2.2.2.2, 2.2.2.2' options.tdstream = '1.1.1.1, 2.2.2.2, 2.2.2.2'
proxies = set(['1.1.1.1', '2.2.2.2']) tdstream = set(['1.1.1.1', '2.2.2.2'])
self.assertEqual(get_trusted_downstream(options), proxies) self.assertEqual(get_trusted_downstream(options), tdstream)
options.proxies = '1.1.1.1, 2.2.2.' options.tdstream = '1.1.1.1, 2.2.2.'
with self.assertRaises(ValueError): with self.assertRaises(ValueError):
get_trusted_downstream(options), proxies get_trusted_downstream(options), tdstream
...@@ -36,9 +36,9 @@ def main(): ...@@ -36,9 +36,9 @@ def main():
logging.info('Listening on {}:{}'.format(options.address, options.port)) logging.info('Listening on {}:{}'.format(options.address, options.port))
if ssl_ctx: if ssl_ctx:
server_settings.update(ssl_options=ssl_ctx) server_settings.update(ssl_options=ssl_ctx)
app.listen(options.sslPort, options.sslAddress, **server_settings) app.listen(options.sslport, options.ssladdress, **server_settings)
logging.info('Listening on ssl {}:{}'.format(options.sslAddress, logging.info('Listening on ssl {}:{}'.format(options.ssladdress,
options.sslPort)) options.sslport))
loop.start() loop.start()
......
...@@ -19,17 +19,17 @@ def print_version(flag): ...@@ -19,17 +19,17 @@ def print_version(flag):
define('address', default='127.0.0.1', help='Listen address') define('address', default='127.0.0.1', help='Listen address')
define('port', type=int, default=8888, help='Listen port') define('port', type=int, default=8888, help='Listen port')
define('sslAddress', default='0.0.0.0', help='SSL listen address') define('ssladdress', default='0.0.0.0', help='SSL listen address')
define('sslPort', type=int, default=4433, help='SSL listen port') define('sslport', type=int, default=4433, help='SSL listen port')
define('certfile', default='', help='SSL certificate file') define('certfile', default='', help='SSL certificate file')
define('keyfile', default='', help='SSL private key file') define('keyfile', default='', help='SSL private key file')
define('debug', type=bool, default=False, help='Debug mode') define('debug', type=bool, default=False, help='Debug mode')
define('policy', default='warning', define('policy', default='warning',
help='Missing host key policy, reject|autoadd|warning') help='Missing host key policy, reject|autoadd|warning')
define('hostFile', default='', help='User defined host keys file') define('hostfile', default='', help='User defined host keys file')
define('sysHostFile', default='', help='System wide host keys file') define('syshostfile', default='', help='System wide host keys file')
define('proxies', default='', help='trusted downstream, separated by comma') define('tdstream', default='', help='trusted downstream, separated by comma')
define('wpIntvl', type=int, default=0, help='Websocket ping interval') define('wpintvl', type=int, default=0, help='Websocket ping interval')
define('version', type=bool, help='Show version information', define('version', type=bool, help='Show version information',
callback=print_version) callback=print_version)
...@@ -44,7 +44,7 @@ def get_app_settings(options): ...@@ -44,7 +44,7 @@ def get_app_settings(options):
settings = dict( settings = dict(
template_path=os.path.join(base_dir, 'webssh', 'templates'), template_path=os.path.join(base_dir, 'webssh', 'templates'),
static_path=os.path.join(base_dir, 'webssh', 'static'), static_path=os.path.join(base_dir, 'webssh', 'static'),
websocket_ping_interval=options.wpIntvl, websocket_ping_interval=options.wpintvl,
debug=options.debug, debug=options.debug,
xsrf_cookies=True xsrf_cookies=True
) )
...@@ -61,16 +61,16 @@ def get_server_settings(options): ...@@ -61,16 +61,16 @@ def get_server_settings(options):
def get_host_keys_settings(options): def get_host_keys_settings(options):
if not options.hostFile: if not options.hostfile:
host_keys_filename = os.path.join(base_dir, 'known_hosts') host_keys_filename = os.path.join(base_dir, 'known_hosts')
else: else:
host_keys_filename = options.hostFile host_keys_filename = options.hostfile
host_keys = load_host_keys(host_keys_filename) host_keys = load_host_keys(host_keys_filename)
if not options.sysHostFile: if not options.syshostfile:
filename = os.path.expanduser('~/.ssh/known_hosts') filename = os.path.expanduser('~/.ssh/known_hosts')
else: else:
filename = options.sysHostFile filename = options.syshostfile
system_host_keys = load_host_keys(filename) system_host_keys = load_host_keys(filename)
settings = dict( settings = dict(
...@@ -106,10 +106,10 @@ def get_ssl_context(options): ...@@ -106,10 +106,10 @@ def get_ssl_context(options):
def get_trusted_downstream(options): def get_trusted_downstream(options):
proxies = set() tdstream = set()
for ip in options.proxies.split(','): for ip in options.tdstream.split(','):
ip = ip.strip() ip = ip.strip()
if ip: if ip:
to_ip_address(ip) to_ip_address(ip)
proxies.add(ip) tdstream.add(ip)
return proxies return tdstream
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment