Implement adjudicated DO items across backend, frontend, deploy
From the ROADMAP adjudication (12 of 13 DO items; D2 is a commit action). Backend: - B3: pytest suite (auth, entity CRUD, rollup) + dev deps + pytest config - B4: cap document uploads at TEN31_MAX_UPLOAD_SIZE (default 50MB), stream- checked with partial-file cleanup, 413 on overflow - B7: type AuditLog.detail as dict|list|str|None to match the JSON column - B10: index foreign-key columns (migration a7b8c9d0e1f2 + index=True) - B11: cli delete-user logs file-removal errors instead of swallowing them Frontend: - F2: distinguish "server unreachable" from "logged out"; retry prompt - F4: confirm before destructive holdings-replace on import; step progress - F6: expandable audit-log detail with full JSON - F7: empty-state on the Investments page - F8: shared role helpers (WRITER_ROLES/canEditRound/isApprover), used by EntitiesList, AuditLog, Import, ValuationWorkflow Deploy: - D5: run tsc --noEmit before packaging (build script) - D6: TEN31_LOG_LEVEL env var (defaults to info) Verified: 8/8 backend tests pass; alembic upgrades to head with 13 FK indexes; upload limit rejects oversized + cleans up; frontend tsc + vite build clean; dev server serves and proxies to the API.
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
"""Auth: login works, and protected/writer endpoints reject the wrong caller."""
|
||||
|
||||
from tests.conftest import make_user
|
||||
from ten31portal.models import UserRole
|
||||
|
||||
|
||||
def test_login_success(client, approver):
|
||||
resp = client.post(
|
||||
"/api/auth/login", json={"login": "approver", "password": "password123"}
|
||||
)
|
||||
assert resp.status_code == 200, resp.text
|
||||
assert resp.json()["username"] == "approver"
|
||||
|
||||
|
||||
def test_login_wrong_password(client, approver):
|
||||
resp = client.post(
|
||||
"/api/auth/login", json={"login": "approver", "password": "nope"}
|
||||
)
|
||||
assert resp.status_code == 401
|
||||
|
||||
|
||||
def test_me_requires_authentication(client):
|
||||
assert client.get("/api/auth/me").status_code == 401
|
||||
|
||||
|
||||
def test_me_returns_current_user(auth_client):
|
||||
resp = auth_client.get("/api/auth/me")
|
||||
assert resp.status_code == 200
|
||||
assert resp.json()["role"] == "approver"
|
||||
|
||||
|
||||
def test_writer_endpoint_rejects_viewer(client, session):
|
||||
"""A viewer is authenticated but not a writer — create-entity must 403, not 401."""
|
||||
make_user(session, username="viewer", role=UserRole.viewer)
|
||||
login = client.post(
|
||||
"/api/auth/login", json={"login": "viewer", "password": "password123"}
|
||||
)
|
||||
assert login.status_code == 200
|
||||
resp = client.post("/api/entities", json={"name": "X", "type": "fund"})
|
||||
assert resp.status_code == 403
|
||||
Reference in New Issue
Block a user