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.
62 lines
1.8 KiB
Python
62 lines
1.8 KiB
Python
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
"""RipeStatValidator + factory + public API tests."""
|
|
from __future__ import annotations
|
|
|
|
import pytest
|
|
|
|
|
|
def test_factory_returns_ripestat_by_default() -> None:
|
|
from decnet.rpki.factory import get_validator
|
|
|
|
v = get_validator()
|
|
assert v.name == "ripestat"
|
|
|
|
|
|
def test_factory_rejects_unknown_provider(monkeypatch: pytest.MonkeyPatch) -> None:
|
|
from decnet.rpki import factory
|
|
|
|
monkeypatch.setenv("DECNET_RPKI_PROVIDER", "nope")
|
|
factory.reset_cache()
|
|
with pytest.raises(ValueError):
|
|
factory.get_validator()
|
|
factory.reset_cache()
|
|
|
|
|
|
def test_enrich_rpki_short_circuits_when_disabled(monkeypatch: pytest.MonkeyPatch) -> None:
|
|
monkeypatch.setenv("DECNET_RPKI_ENABLED", "false")
|
|
from decnet.rpki import enrich_rpki
|
|
|
|
assert enrich_rpki("8.8.8.8", 15169) == (None, None)
|
|
|
|
|
|
def test_enrich_rpki_short_circuits_when_asn_none() -> None:
|
|
from decnet.rpki import enrich_rpki
|
|
|
|
assert enrich_rpki("8.8.8.8", None) == (None, None)
|
|
|
|
|
|
def test_enrich_rpki_returns_status_and_source() -> None:
|
|
from decnet.rpki import enrich_rpki
|
|
|
|
status, source = enrich_rpki("8.8.8.8", 15169)
|
|
assert status in {"valid", "invalid", "not-found", "unknown"}
|
|
assert source == "ripestat"
|
|
|
|
|
|
def test_enrich_rpki_survives_validator_exception(monkeypatch: pytest.MonkeyPatch) -> None:
|
|
from decnet.rpki import factory as rpki_factory
|
|
from decnet.rpki.base import Validator, RpkiResult
|
|
|
|
class BrokenValidator(Validator):
|
|
name = "broken"
|
|
|
|
def validate(self, ip: str, asn: int) -> RpkiResult:
|
|
raise RuntimeError("boom")
|
|
|
|
monkeypatch.setattr(rpki_factory, "_cached", BrokenValidator())
|
|
monkeypatch.setattr(rpki_factory, "_cached_key", "ripestat")
|
|
|
|
from decnet.rpki import enrich_rpki
|
|
|
|
assert enrich_rpki("8.8.8.8", 15169) == (None, None)
|