diff --git a/tests/test_auth.py b/tests/test_auth.py index 90f397f..c988b9b 100644 --- a/tests/test_auth.py +++ b/tests/test_auth.py @@ -655,6 +655,22 @@ def test_public_reads_are_documented_as_unauthenticated(path): assert operation["security"] == [] +def test_every_route_is_in_the_documented_surface(): + """No APIRoute may escape the spec — an undocumented route dodges the pair.""" + from fastapi.routing import APIRoute + from main import app as _app + + spec = _spec() + missing = [] + for route in _app.routes: + if not isinstance(route, APIRoute): # Mount, WebSocket, included routers + continue + for method in route.methods: + if spec["paths"].get(route.path, {}).get(method.lower()) is None: + missing.append(f"{method} {route.path}") + assert missing == [] + + def test_mutating_surface_is_admin_only_except_the_public_three(): """22 mutating operations are published; 19 need the admin session.""" mutating = [(method, path, operation["security"])