Deploy Development / deploy (push) Failing after 40s
Testdaten entstehen nur dort und werden danach entfernt, damit Dev und Produktion sie nicht behalten. Co-authored-by: Cursor <cursoragent@cursor.com>
52 lines
1.8 KiB
Python
52 lines
1.8 KiB
Python
"""Betreiber legt Nutzer an. Andere Konten dürfen das nicht."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from tests.support import ORIGIN, PASSWORD, Actor
|
|
|
|
|
|
def test_session_missing_is_401(client):
|
|
response = client.get("/api/v1/cases")
|
|
assert response.status_code == 401
|
|
|
|
|
|
def test_bootstrap_once_then_superadmin_creates_users(client):
|
|
first = client.post(
|
|
"/api/v1/auth/bootstrap",
|
|
json={"email": "betreiber@example.test", "display_name": "Betreiber", "password": PASSWORD},
|
|
headers={"Origin": ORIGIN},
|
|
)
|
|
assert first.status_code == 201, first.text
|
|
body = first.json()
|
|
assert body["account"]["is_superadmin"] is True
|
|
second = client.post(
|
|
"/api/v1/auth/bootstrap",
|
|
json={"email": "andere@example.test", "display_name": "Andere", "password": PASSWORD},
|
|
headers={"Origin": ORIGIN},
|
|
)
|
|
assert second.status_code == 404
|
|
|
|
owner = Actor(client, "betreiber@example.test", "Betreiber")
|
|
owner.login()
|
|
created = owner.request(
|
|
"POST",
|
|
"/api/v1/accounts",
|
|
json={"email": "mitglied@example.test", "display_name": "Mitglied", "password": PASSWORD},
|
|
status=201,
|
|
)
|
|
assert created["is_superadmin"] is False
|
|
assert "password" not in created
|
|
listed = owner.request("GET", "/api/v1/accounts")
|
|
assert {item["email"] for item in listed["items"]} == {"betreiber@example.test", "mitglied@example.test"}
|
|
assert all("password_hash" not in item and "password" not in item for item in listed["items"])
|
|
|
|
member = Actor(client, "mitglied@example.test", "Mitglied")
|
|
member.login()
|
|
member.request(
|
|
"POST",
|
|
"/api/v1/accounts",
|
|
json={"email": "noch@example.test", "display_name": "Noch", "password": PASSWORD},
|
|
status=403,
|
|
)
|
|
member.request("GET", "/api/v1/accounts", status=403)
|