docs(админка): паритет v1/v2 и дымовой e2e
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
"""P5.1: дымовой e2e API — старый экран и все разделы v2 отвечают."""
|
||||
import importlib
|
||||
import os
|
||||
import sys
|
||||
|
||||
import pytest
|
||||
|
||||
ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
if ROOT not in sys.path:
|
||||
sys.path.insert(0, ROOT)
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
def env(tmp_path, monkeypatch):
|
||||
monkeypatch.setenv("DB_PATH", str(tmp_path / "t.db"))
|
||||
monkeypatch.setenv("SESSION_SECRET", "test-secret")
|
||||
monkeypatch.setenv("AI_BACKEND", "claude")
|
||||
monkeypatch.chdir(ROOT)
|
||||
import auth
|
||||
import db
|
||||
import main
|
||||
for m in (auth, db, main):
|
||||
importlib.reload(m)
|
||||
db.init_db()
|
||||
db.create_user("boss@x", auth.hash_password("Passw0rd!ok"), role="admin")
|
||||
db.admin_verify_user("boss@x")
|
||||
import health_checks
|
||||
monkeypatch.setattr(health_checks, "run_all", lambda: [health_checks.Check("database", True, "ок")])
|
||||
from fastapi.testclient import TestClient
|
||||
client = TestClient(main.app)
|
||||
token = client.post("/api/login", json={"username": "boss@x",
|
||||
"password": "Passw0rd!ok"}).json()["token"]
|
||||
return client, {"Authorization": "Bearer " + token}
|
||||
|
||||
|
||||
def test_legacy_and_v2_sections(env):
|
||||
client, h = env
|
||||
assert client.get("/admin").status_code == 200
|
||||
r = client.get("/admin/v2", headers=h)
|
||||
assert r.status_code == 200 and "unsafe-inline" not in r.headers.get("content-security-policy", "")
|
||||
for path in ("/api/admin/v2/ping", "/api/admin/v2/dashboard", "/api/admin/v2/attention",
|
||||
"/api/admin/v2/customers", "/api/admin/v2/money", "/api/admin/v2/payments",
|
||||
"/api/admin/v2/accounts", "/api/admin/v2/feedback", "/api/admin/v2/system",
|
||||
"/api/admin/v2/sessions", "/api/admin/v2/work/dialogs"):
|
||||
assert client.get(path, headers=h).status_code == 200, path
|
||||
Reference in New Issue
Block a user