feat: FastAPI-App mit API-Key- und Session-Auth

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
2026-07-17 18:03:24 +02:00
parent 101ee01af1
commit a10f4d0b57
4 changed files with 126 additions and 1 deletions

View File

@@ -0,0 +1,14 @@
def test_api_requires_key(client):
assert client.get("/api/accounts").status_code == 401
r = client.get("/api/accounts", headers={"Authorization": "Bearer test-key"})
assert r.status_code == 200
def test_login_flow(client):
r = client.post("/login", data={"username": "admin", "password": "falsch"},
follow_redirects=False)
assert r.status_code == 401
r = client.post("/login", data={"username": "admin", "password": "geheim"},
follow_redirects=False)
assert r.status_code == 303
assert client.get("/api/accounts").status_code == 200 # Cookie reicht