feat: add password login and bearer sessions
- Argon2id password hashes, KDF in a thread with its own limit - POST /auth/sessions with Basic, DELETE /auth/sessions/current - Bearer sessions in PostgreSQL, X-User-Id ignored - migration drops lab 1 data without passwords - student-tests on tokens, sessions spec and synced specs Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -5,7 +5,7 @@ from typing import Any
|
||||
|
||||
import pytest
|
||||
|
||||
from api_client import API, Actor, Api, unique_username
|
||||
from api_client import API, Actor, Api, registration, unique_username
|
||||
from contract import (
|
||||
assert_created_at,
|
||||
assert_error,
|
||||
@@ -93,7 +93,7 @@ def test_error_request_id_matches_header(
|
||||
resp = api.request(
|
||||
"POST",
|
||||
f"{API}/users",
|
||||
json={"username": alice.user["username"], "display_name": "Alice"},
|
||||
json=registration(alice.username, "Alice"),
|
||||
)
|
||||
assert_error(resp, 409)
|
||||
|
||||
@@ -103,7 +103,7 @@ def test_no_fastapi_detail(api: Api, alice: Actor) -> None:
|
||||
validation = api.request(
|
||||
"POST",
|
||||
f"{API}/users",
|
||||
json={"username": "ab", "display_name": "x"},
|
||||
json=registration("ab", "x"),
|
||||
)
|
||||
not_found = api.request("GET", f"{API}/unknown", actor=alice)
|
||||
for resp, status in ((validation, 400), (not_found, 404)):
|
||||
@@ -126,11 +126,7 @@ def test_extra_field(api: Api, alice: Actor) -> None:
|
||||
resp = api.request(
|
||||
"POST",
|
||||
f"{API}/users",
|
||||
json={
|
||||
"username": unique_username(),
|
||||
"display_name": "Extra",
|
||||
"is_admin": True,
|
||||
},
|
||||
json={**registration(unique_username(), "Extra"), "is_admin": True},
|
||||
)
|
||||
assert_error(resp, 400)
|
||||
resp = api.request(
|
||||
@@ -148,7 +144,7 @@ def test_wrong_type_is_not_coerced(api: Api) -> None:
|
||||
resp = api.request(
|
||||
"POST",
|
||||
f"{API}/users",
|
||||
json={"username": username, "display_name": 123},
|
||||
json=registration(username, 123),
|
||||
)
|
||||
assert_error(resp, 400)
|
||||
# пользователь не создан: то же имя свободно
|
||||
|
||||
Reference in New Issue
Block a user