Commit 499f3b6d by Sheng

Lowercase all option names

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