Files
ddns-monitor/tests/contracts/conftest.py
T
kiskaadee 1126522109 test(contracts): add verified No-IP Class A contract assertions and specification
- Add test_noip_contract.py asserting DynDNS2 basic auth, DDNS key group scoping, and idempotency
- Add noip_config fixture in conftest.py
- Document empirical findings in docs/contracts/class-a-noip.md
- Record No-IP edge invariants: HTTP 429 rate limiting, unauthenticated IP short-circuiting,
  and RFC 5737 bogon address filtering
2026-10-30 01:54:22 -05:00

53 lines
1.9 KiB
Python

import tomllib
from pathlib import Path
import pytest
CONFIG_PATH = Path(__file__).parent / "contracts.local.toml"
@pytest.fixture(scope="session")
def raw_config():
if not CONFIG_PATH.exists():
pytest.skip(f"Contract test configuration not found at {CONFIG_PATH}")
with open(CONFIG_PATH, "rb") as f:
return tomllib.load(f)
@pytest.fixture(scope="session")
def general_config(raw_config):
return raw_config.get("general", {})
@pytest.fixture(scope="session")
def dynu_config(raw_config, general_config):
cfg = raw_config.get("dynu", {})
if not cfg.get("enabled", False):
pytest.skip("Dynu contract tests are disabled in contracts.local.toml")
return {
**{k: v.strip() if isinstance(v, str) else v for k, v in cfg.items()},
"test_ipv4": str(general_config.get("test_ipv4", "198.51.100.42")).strip(),
"test_ipv6": str(general_config.get("test_ipv6", "2001:db8::42")).strip(),
}
@pytest.fixture(scope="session")
def duckdns_config(raw_config, general_config):
cfg = raw_config.get("duckdns", {})
if not cfg.get("enabled", False):
pytest.skip("DuckDNS contract tests are disabled in contracts.local.toml")
return {
**{k: v.strip() if isinstance(v, str) else v for k, v in cfg.items()},
"test_ipv4": str(general_config.get("test_ipv4", "198.51.100.42")).strip(),
"test_ipv6": str(general_config.get("test_ipv6", "2001:db8::42")).strip(),
}
@pytest.fixture(scope="session")
def noip_config(raw_config, general_config):
cfg = raw_config.get("noip", {})
if not cfg.get("enabled", False):
pytest.skip("No-IP contract tests are disabled in contracts.local.toml")
return {
**{k: v.strip() if isinstance(v, str) else v for k, v in cfg.items()},
"test_ipv4": str(general_config.get("test_ipv4", "198.51.100.42")).strip(),
"test_ipv6": str(general_config.get("test_ipv6", "2001:db8::42")).strip(),
}