def test_invalid_jwt_master_key(self): os.environ["JWT_MASTER_KEY"] = "blah" with self.assertRaises(ConfigError): initialize_config() del os.environ["JWT_MASTER_KEY"]
def test_invalid_jwt_algorithm(self): os.environ["JWT_ALGORITHM"] = "blah" os.environ["JWT_MASTER_KEY"] = "passwordpassword" settings = initialize_config() self.assertEqual(settings["JWT_ALGORITHM"], "HS256")
def create_app(): """ Initializes the Flask application. """ structured_log(level='info', msg="Starting beesly...") try: settings = initialize_config() except ConfigError: structured_log(level='critical', msg="Failed to load configuration. Exiting...") sys.exit(4) # enable Swagger UI if running in DEV mode if settings["DEV"]: app.static_folder = os.path.dirname(os.path.realpath(__file__)) + "/swagger-ui" app.add_url_rule("/service/docs/<path:filename>", endpoint="/service/docs", view_func=app.send_static_file) app.config.update(settings) structured_log(level='info', msg="Successfully loaded configuration") rlimiter.init_app(app) return app
def test_invalid_jwt_validity_period(self): os.environ["JWT_VALIDITY_PERIOD"] = "blah" settings = initialize_config() self.assertEqual(settings["JWT_VALIDITY_PERIOD"], 900)
def test_invalid_rate_limit_strategy_storage_memcached(self): os.environ["RATELIMIT_STRATEGY"] = "moving-window" os.environ["RATELIMIT_STORAGE_URL"] = "memcached://localhost:11211" with self.assertRaises(ConfigError): initialize_config()
def test_invalid_rate_limit_storage_backend(self): os.environ["RATELIMIT_STORAGE_URL"] = "blah" with self.assertRaises(ConfigError): initialize_config()
def test_invalid_rate_limit_strategy(self): os.environ["RATELIMIT_STRATEGY"] = "blah" with self.assertRaises(ConfigError): initialize_config()
def test_invalid_pam_service(self): os.environ["PAM_SERVICE"] = "blah" with self.assertRaises(ConfigError): initialize_config()