Skip to content
Snippets Groups Projects
Commit 7397110d authored by Nicolas Dandrimont's avatar Nicolas Dandrimont
Browse files

server: ensure check_config is called during app instantiation

check_config converts the "stored" configuration (with toplevel keys for
most services) into a config suitable for the ``get_vault`` function.

Ensure all tests use the same codepath to make sure it is properly
exercized, and that the vault backend object can be properly initialized
in all cases.
parent 456eb8f4
No related branches found
No related tags found
1 merge request!145server: ensure check_config is called during app instantiation
......@@ -107,6 +107,7 @@ def make_app_from_configfile(
raise ValueError(f"Configuration path {config_path} should exist.")
app_config = read_raw_config(config_basepath(config_path))
app_config["vault"] = check_config(app_config)
app.config.update(merge_configs(DEFAULT_CONFIG, app_config))
return app
......
......@@ -13,7 +13,7 @@ import yaml
from swh.core.api.serializers import json_dumps, msgpack_dumps, msgpack_loads
from swh.vault.api.serializers import ENCODERS
import swh.vault.api.server
from swh.vault.api.server import app, check_config, make_app_from_configfile
from swh.vault.api.server import app, check_config, get_vault, make_app_from_configfile
from swh.vault.tests.test_backend import TEST_SWHID
......@@ -59,7 +59,7 @@ def test_make_app_from_env_variable(swh_vault_server_config_file):
"""
app = make_app_from_configfile()
assert app is not None
assert "vault" in app.config
assert get_vault() is not None
# Cleanup app
del app.config["vault"]
......@@ -76,7 +76,7 @@ def test_make_app_from_file(swh_vault_server_config, tmp_path):
app = make_app_from_configfile(conf_path)
assert app is not None
assert "vault" in app.config
assert get_vault() is not None
# Cleanup app
del app.config["vault"]
......@@ -84,9 +84,8 @@ def test_make_app_from_file(swh_vault_server_config, tmp_path):
@pytest.fixture
def vault_app(swh_vault_server_config):
app.config["vault"] = check_config(swh_vault_server_config)
yield app
def vault_app(swh_vault_server_config_file):
yield make_app_from_configfile()
# Cleanup app
del app.config["vault"]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment