def test_get_policy_setting(self): options.policy = 'warning' 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 = '' 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 = '' settings = get_host_keys_settings(options) try: instance = get_policy_setting(options, settings) except ValueError: self.assertFalse(settings['host_keys'] and settings['system_host_keys']) else: self.assertIsInstance(instance, paramiko.client.RejectPolicy)
def make_handlers(loop, options): host_keys_settings = get_host_keys_settings(options) policy = get_policy_setting(options, host_keys_settings) handlers = [(r"/", IndexHandler, dict(loop=loop, policy=policy, host_keys_settings=host_keys_settings)), (r'/ws', WsockHandler, dict(loop=loop))] return handlers
def test_get_host_keys_settings(self): options.hostFile = '' options.sysHostFile = '' dic = get_host_keys_settings(options) filename = os.path.join(base_dir, 'known_hosts') self.assertEqual(dic['host_keys'], load_host_keys(filename)) self.assertEqual(dic['host_keys_filename'], filename) self.assertEqual( dic['system_host_keys'], load_host_keys(os.path.expanduser('~/.ssh/known_hosts'))) options.hostFile = 'tests/known_hosts_example' options.sysHostFile = 'tests/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['system_host_keys'], load_host_keys(options.sysHostFile))
def main(): parse_command_line() app_settings = get_app_settings(options) host_keys_settings = get_host_keys_settings(options) policy = get_policy_setting(options, host_keys_settings) loop = tornado.ioloop.IOLoop.current() app = make_app(loop, policy, host_keys_settings, app_settings) app.listen(options.port, options.address) logging.info('Listening on {}:{}'.format(options.address, options.port)) loop.start()
def main(): parse_command_line() app_settings = get_app_settings(options) host_keys_settings = get_host_keys_settings(options) policy = get_policy_setting(options, host_keys_settings) loop = tornado.ioloop.IOLoop.current() handlers = [(r'/', IndexHandler, dict(loop=loop, policy=policy, host_keys_settings=host_keys_settings)), (r'/ws', WsockHandler, dict(loop=loop))] app = tornado.web.Application(handlers, **app_settings) app.listen(options.port, options.address) logging.info('Listening on {}:{}'.format(options.address, options.port)) loop.start()