"""Tests for the AZ-407 MAVLink test passkey fixture (AC-5).""" from __future__ import annotations from pathlib import Path REPO_ROOT = Path(__file__).resolve().parents[3] PASSKEY_PATH = REPO_ROOT / "e2e" / "fixtures" / "secrets" / "mavlink-test-passkey.txt" def _hex_lines(path: Path) -> list[str]: """Return non-comment, non-blank stripped lines.""" out: list[str] = [] for raw in path.read_text().splitlines(): line = raw.strip() if not line or line.startswith("#"): continue out.append(line) return out def test_passkey_has_comment_header() -> None: """AC-5: the first line is the human-readable test-only header.""" # Arrange first_line = PASSKEY_PATH.read_text().splitlines()[0] # Assert assert first_line.startswith("# TEST ONLY") assert "not for production use" in first_line def test_passkey_is_64_hex_chars() -> None: """AC-5: the secret line is exactly 64 hex chars (32 bytes).""" # Arrange lines = _hex_lines(PASSKEY_PATH) # Assert assert len(lines) == 1, f"expected one hex line, got {len(lines)}" secret = lines[0] assert len(secret) == 64, f"passkey length {len(secret)}, expected 64" int(secret, 16) # raises ValueError if not hex def test_passkey_is_lowercase() -> None: """Conventionally lowercase so byte-equality comparisons are stable.""" # Arrange secret = _hex_lines(PASSKEY_PATH)[0] # Assert assert secret == secret.lower()