from pathlib import Path from typing import Any from gewu.bootstrap.app import create_local_app from gewu.domain.operations import OPERATIONS, Transport, operations_for def test_http_openapi_routes_match_the_explicit_operation_allowlist( tmp_path: Path, monkeypatch: Any ) -> None: monkeypatch.setenv("GEWU_DATA_ROOT", str(tmp_path / "gewu-data")) app = create_local_app() schema = app.openapi() exposed = { operation["operationId"]: operation for methods in schema["paths"].values() for method, operation in methods.items() if method in {"get", "post", "put", "delete", "patch"} } http_allowlist = {item.name for item in operations_for(Transport.HTTP)} operation_index = {item.name: item for item in OPERATIONS} assert set(exposed) == http_allowlist assert "owner_decide" not in exposed assert "proposal_submit" not in exposed assert all( not operation_index[name].mutates_knowledge for name, route in exposed.items() if "knowledge" in route.get("tags", []) )