This commit is contained in:
1 parent
4db3f45164
commit
d25c04cdd2
175 files changed
+56243
-15
No files matched your search
@@ -0,0 +1,30 @@
|
||||
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", [])
|
||||
)
|
||||
Reference in new issue
Block a user