feat: FastAPI-App mit API-Key- und Session-Auth
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
14
finance/tests/test_auth.py
Normal file
14
finance/tests/test_auth.py
Normal 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
|
||||
Reference in New Issue
Block a user