Files
periscope/tests/test_periscope_csp_middleware_rewrite.py
michele 22bc075c58 Stamp 2.58.0 native JWT middleware and useAuthApi.
Same skip paths, Bearer/query token, Clerk RS256 leftover, and local HS256
contract. routers/auth.py, user records, and AUTH_JWT_SECRET are untouched.
2026-09-20 21:01:51 +02:00

30 lines
1.1 KiB
Python

"""CSP host seam and middleware package live under periscope/src."""
from __future__ import annotations
from pathlib import Path
ROOT = Path(__file__).resolve().parents[1]
FE = ROOT / "periscope" / "src" / "frontend" / "src" / "lib" / "csp-hosts.ts"
MW = ROOT / "periscope" / "src" / "backend" / "middleware" / "__init__.py"
def test_csp_hosts_are_src():
text = FE.read_text(encoding="utf-8")
assert "Native Periscope overlay" not in text[:400]
assert "export const CSP_SCRIPT_HOSTS" in text
assert "export const CSP_CONNECT_HOSTS" in text
assert "export const CSP_FRAME_HOSTS" in text
assert "http://127.0.0.1:8080" in text
assert "http://localhost:18741" in text
def test_middleware_package_is_src_and_does_not_export_auth():
text = MW.read_text(encoding="utf-8")
assert text.strip()
assert "from backend.middleware.auth" not in text
assert "verify_request_user" not in text
auth = ROOT / "periscope" / "src" / "backend" / "middleware" / "auth.py"
assert auth.is_file()
assert "verify_request_user" in auth.read_text(encoding="utf-8")