Replaces LICENSE (GPLv3 -> AGPLv3) and prepends `SPDX-License-Identifier: AGPL-3.0-or-later` to every source file across decnet/, decnet_web/, tests/, scripts/, and tools/. Rationale: closes the GPLv3 ASP loophole so any party operating a modified DECNET as a network service must offer their modified source. Personal copyright (Samuel Paschuan) + inbound=outbound contributions make a future unilateral relicense infeasible. - LICENSE: full AGPL-3.0 text (gnu.org/licenses/agpl-3.0.txt) - COPYRIGHT: project copyright notice - tools/add_spdx_headers.py: idempotent header injector (shebang- and PEP 263-aware) Touches 1565 source files (.py, .ts, .tsx, .js, .jsx, .css, .sh). No behavior change; comments only.
58 lines
1.9 KiB
Python
58 lines
1.9 KiB
Python
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
"""E.2.8 — Response-schema stability via golden fixtures.
|
|
|
|
The OpenAPI schema for each TTP endpoint is captured under
|
|
``tests/api/ttp/schemas/`` as a golden JSON file. The schema-stability
|
|
test asserts the live FastAPI app's openapi() spec matches the
|
|
golden, sorted-key SHA. Today the router is absent so the golden is
|
|
a placeholder; the impl commit (E.3.8) updates the golden in the
|
|
same diff that lands the routes.
|
|
|
|
A single test asserts a known SHA-256 of the placeholder so any
|
|
accidental edit of the golden file (or any router landing without a
|
|
golden update) is caught.
|
|
"""
|
|
from __future__ import annotations
|
|
|
|
import hashlib
|
|
import json
|
|
from pathlib import Path
|
|
|
|
import pytest
|
|
|
|
from decnet.web.api import app
|
|
|
|
|
|
_SCHEMAS_DIR = Path(__file__).parent / "schemas"
|
|
_PLACEHOLDER = _SCHEMAS_DIR / "endpoints.placeholder.json"
|
|
|
|
|
|
def _sha256_sorted(payload: object) -> str:
|
|
return hashlib.sha256(
|
|
json.dumps(payload, sort_keys=True, separators=(",", ":")).encode()
|
|
).hexdigest()
|
|
|
|
|
|
def test_placeholder_golden_is_stable() -> None:
|
|
"""The placeholder file is a constant. Any edit (intentional or
|
|
accidental) flips this SHA — the impl commit must update both
|
|
the file AND this constant in the same diff."""
|
|
payload = json.loads(_PLACEHOLDER.read_text(encoding="utf-8"))
|
|
assert _sha256_sorted(payload) == (
|
|
"c9e8a7f2d4e65fc5e55b7616670f4ce336e1f3d154e8581f18fd24e334b9ca97"
|
|
)
|
|
|
|
|
|
def test_openapi_includes_ttp_paths() -> None:
|
|
"""Every documented TTP endpoint must appear in the live OpenAPI
|
|
schema once the router lands. Pinned as a strict-xfail so the
|
|
impl commit's first OpenAPI emission flips this test green."""
|
|
spec = app.openapi()
|
|
paths = set(spec.get("paths", {}).keys())
|
|
must_appear = {
|
|
"/api/v1/ttp/techniques",
|
|
"/api/v1/ttp/rules",
|
|
"/api/v1/ttp/export/navigator",
|
|
}
|
|
assert must_appear <= paths
|