Kairo-Jinkendo/backend/tests/test_rights_registry.py
Lars db06af0489
All checks were successful
Deploy Development / deploy (push) Successful in 47s
Test Suite / pytest-backend (push) Successful in 42s
Test Suite / lint-backend (push) Successful in 2s
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 12s
AP0.7: Tenant Hardening, Actor Directory und Data Layer Minimum
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-05 07:25:01 +02:00

47 lines
1.4 KiB
Python

"""Rights registry and DB sync tests."""
from __future__ import annotations
import rights_registrations # noqa: F401
from db import get_connection
from rights_registry import get_registered_capabilities, sync_rights_registry_to_db
def test_registry_contains_initial_capabilities():
keys = {reg.key for reg in get_registered_capabilities()}
assert keys == {
"kairo.admin.access",
"kairo.tenant.manage",
"kairo.actor.manage",
"kairo.actor.read",
"kairo.context.read",
"kairo.entitlements.read",
"kairo.feature.registry.read",
"kairo.feature.registry.manage",
"kairo.prompt.registry.read",
"kairo.prompt.registry.manage",
"kairo.config.registry.read",
"kairo.config.registry.manage",
"kairo.prompt.render",
"kairo.initiative.read",
"kairo.initiative.manage",
"kairo.action.read",
"kairo.action.manage",
"kairo.workspace.read",
}
def test_sync_is_idempotent():
assert sync_rights_registry_to_db() == 0
assert sync_rights_registry_to_db() == 0
conn = get_connection()
try:
with conn.cursor() as cur:
cur.execute("SELECT COUNT(*) FROM capabilities")
assert cur.fetchone()[0] == 18
cur.execute("SELECT COUNT(*) FROM role_capability_grants")
assert cur.fetchone()[0] >= 5
finally:
conn.close()