- User id/login = username (was email). Email is a separate settable field. - Default admin: username admin / password 1234, must_setup=True. - Login forces /setup on first login: set email + change password, then clears must_setup. - New /api/auth/setup endpoint; JWT sub = username; admin routes use username. - Frontend: Login uses username, router guard forces /setup, new Setup.vue (email + new password + confirm), i18n EN/TH. - Tests: test_setup.py added; all suites adapted (m0/m1/routes/security/setup/e2e) PASS.
52 lines
1.8 KiB
Python
52 lines
1.8 KiB
Python
"""Verify full backend imports + all routes registered (no LLM needed)."""
|
|
import os
|
|
import sys
|
|
import tempfile
|
|
import warnings
|
|
from pathlib import Path
|
|
|
|
warnings.filterwarnings("ignore", message="The HMAC key is")
|
|
sys.path.insert(0, os.path.join(os.path.dirname(os.path.abspath(__file__)), ".."))
|
|
|
|
tempdir = tempfile.mkdtemp(prefix="st_import_")
|
|
os.environ["DATA_DIR"] = tempdir
|
|
os.environ["JWT_SECRET"] = "test-secret-key-0123456789abcdef"
|
|
|
|
from app.factory import create_app # noqa: E402
|
|
from app.config import Config # noqa: E402
|
|
|
|
Config.DATA_DIR = Path(tempdir)
|
|
Config.LLM_API_KEY = ""
|
|
Config.LLM_BASE_URL = ""
|
|
|
|
|
|
def main():
|
|
app = create_app()
|
|
rules = sorted({str(rule) for rule in app.url_map.iter_rules() if str(rule).startswith("/api")})
|
|
expected = [
|
|
"/api/auth/login", "/api/auth/me", "/api/auth/setup",
|
|
"/api/admin/users", "/api/admin/users/<username>",
|
|
"/api/groups", "/api/groups/<gid>",
|
|
"/api/groups/<gid>/analyze", "/api/groups/<gid>/personas",
|
|
"/api/groups/<gid>/personas/<pid>", "/api/groups/<gid>/personas/<pid>",
|
|
"/api/groups/<gid>/reanalyze",
|
|
"/api/chat/<gid>/personas/<pid>/chat/start",
|
|
"/api/chat/<gid>/personas/<pid>/chat/send",
|
|
"/api/chat/<gid>/personas/<pid>/chat/finish",
|
|
"/api/chat/sessions", "/api/chat/sessions/<sid>",
|
|
"/api/me/board", "/api/me/weak-areas", "/api/me/personas",
|
|
"/api/me/personas/generate",
|
|
"/api/analytics",
|
|
]
|
|
missing = [e for e in expected if e not in rules]
|
|
if missing:
|
|
raise SystemExit(f"MISSING ROUTES: {missing}")
|
|
print(f"[ok] all {len(expected)} expected routes registered")
|
|
for r in sorted(rules):
|
|
print(" ", r)
|
|
print("ALL ROUTE REGISTRATION TESTS PASSED")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|