Kairo-Jinkendo/backend/tests/test_config_registry.py
Lars 53047b6c16
All checks were successful
Deploy Development / deploy (push) Successful in 38s
Test Suite / pytest-backend (push) Successful in 18s
Test Suite / lint-backend (push) Successful in 1s
Test Suite / compose-smoke (push) Has been skipped
Test Suite / k6 /api/health Baseline (push) Successful in 18s
Test Suite / playwright-smoke (push) Successful in 24s
AP0.4: Feature-, Prompt- und Config-Registry mit Single-Render und Entitlements-Features.
Migration 005, Registry-Sync, Placeholder-Validation, capability-geschuetzte API, Tests und Abschlussbericht v0.1.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-04 23:29:02 +02:00

67 lines
2.0 KiB
Python

"""Configuration registry tests."""
from __future__ import annotations
import pytest
from auth import AUTH_HEADER
from config_service import SECRET_VALUE_FORBIDDEN, get_config, list_configs, upsert_config
from tests.factories import provision_user_in_tenant
def test_global_config_upsert_and_read():
upsert_config(
config_key="test.ap0.config",
scope="global",
value="enabled",
value_type="string",
description="pytest config",
)
item = get_config("test.ap0.config", scope="global")
assert item is not None
assert item["value"] == "enabled"
def test_secret_config_rejects_plaintext():
with pytest.raises(ValueError, match=SECRET_VALUE_FORBIDDEN):
upsert_config(
config_key="test.secret",
scope="global",
value="super-secret-token",
is_secret=True,
)
def test_config_api(client):
user = provision_user_in_tenant(portal_role="admin", tenant_role="owner")
login = client.post(
"/api/auth/login",
json={"email": user["email"], "password": user["password"]},
)
token = login.json()["token"]
res = client.get("/api/config", headers={AUTH_HEADER: token})
assert res.status_code == 200
keys = {item["config_key"] for item in res.json()}
assert "prompt.default_execution_mode" in keys
def test_config_post_api(client):
user = provision_user_in_tenant(portal_role="admin", tenant_role="owner")
login = client.post(
"/api/auth/login",
json={"email": user["email"], "password": user["password"]},
)
token = login.json()["token"]
res = client.post(
"/api/config",
json={
"config_key": "test.api.config",
"scope": "global",
"value": True,
"value_type": "boolean",
"description": "via api",
},
headers={AUTH_HEADER: token},
)
assert res.status_code == 200
assert res.json()["config_key"] == "test.api.config"