Kairo-Jinkendo/backend/tests/test_entitlements.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

33 lines
1.2 KiB
Python

"""Entitlements snapshot tests."""
from __future__ import annotations
from auth import AUTH_HEADER
from tests.factories import provision_user_in_tenant
def test_entitlements_snapshot_shape(client):
user = provision_user_in_tenant(tenant_role="owner", portal_role="admin")
login = client.post(
"/api/auth/login",
json={"email": user["email"], "password": user["password"]},
)
token = login.json()["token"]
res = client.get("/api/me/entitlements", headers={AUTH_HEADER: token})
assert res.status_code == 200
body = res.json()
assert "account" in body
assert body["account"]["portal_role"] == "admin"
assert "capabilities" in body["account"]
assert body["tenant"]["tenant_id"] == user["tenant_id"]
assert body["actor"]["actor_id"] == user["actor_id"]
assert body["roles"]["portal"] == "admin"
assert body["roles"]["tenant"] == "owner"
assert "kairo.admin.access" in body["capabilities"]
assert body["enforcement"]["capabilities"] in ("probe", "enforce")
assert body["enforcement"]["features"] == "probe"
assert "kairo.prompt.registry" in body["features"]
assert body["features"]["kairo.prompt.registry"]["enabled"] is True