mirror of
http://112.124.100.131/huang.ze/ebiz-dify-ai.git
synced 2025-12-09 10:56:52 +08:00
refactor: extract cors configs into dify config and cleanup the config class (#5507)
Co-authored-by: takatost <takatost@gmail.com>
This commit is contained in:
@@ -15,6 +15,7 @@ def example_env_file(tmp_path, monkeypatch) -> str:
|
||||
file_path.write_text(dedent(
|
||||
"""
|
||||
CONSOLE_API_URL=https://example.com
|
||||
CONSOLE_WEB_URL=https://example.com
|
||||
"""))
|
||||
return str(file_path)
|
||||
|
||||
@@ -47,14 +48,13 @@ def test_flask_configs(example_env_file):
|
||||
flask_app.config.from_mapping(DifyConfig(_env_file=example_env_file).model_dump())
|
||||
config = flask_app.config
|
||||
|
||||
# configs read from dotenv directly
|
||||
assert config['LOG_LEVEL'] == 'INFO'
|
||||
|
||||
# configs read from pydantic-settings
|
||||
assert config['LOG_LEVEL'] == 'INFO'
|
||||
assert config['COMMIT_SHA'] == ''
|
||||
assert config['EDITION'] == 'SELF_HOSTED'
|
||||
assert config['API_COMPRESSION_ENABLED'] is False
|
||||
assert config['SENTRY_TRACES_SAMPLE_RATE'] == 1.0
|
||||
assert config['TESTING'] == False
|
||||
|
||||
# value from env file
|
||||
assert config['CONSOLE_API_URL'] == 'https://example.com'
|
||||
@@ -71,3 +71,7 @@ def test_flask_configs(example_env_file):
|
||||
'pool_recycle': 3600,
|
||||
'pool_size': 30,
|
||||
}
|
||||
|
||||
assert config['CONSOLE_WEB_URL']=='https://example.com'
|
||||
assert config['CONSOLE_CORS_ALLOW_ORIGINS']==['https://example.com']
|
||||
assert config['WEB_API_CORS_ALLOW_ORIGINS'] == ['*']
|
||||
|
||||
Reference in New Issue
Block a user