zapret-kvn/tests/real_naive_key.py
loop-uh 3054036b4c
Some checks failed
Windows project source guards / test (push) Has been cancelled
NaiveProxy keys run on the stock naive client (core/naive.exe) as a loopback SOCKS helper behind sing-box
naive+https:// keys of the VPN bot are imported (paste, file, QR, subscription text), planned as a naive sidecar and
started by NaiveManager; the key line never reaches sing-box, logs or exports. Core pinned in the core lock
(klzgrad/naiveproxy v154.0.8037.49-5, SHA-256), resolved and verified like the other cores. Live run with a real canary
key passes on win10 (real planner, real sing-box.exe, stock naive.exe).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-27 06:00:21 -05:00

39 lines
1.3 KiB
Python

"""The real NaiveProxy test key of the vpnbot canary as test data (owner decision 2026-11-25: tests run on real data).
The file ``~/.config/kvn-test-naive-key`` (override: ``KVN_TEST_NAIVE_KEY``; on CT 201 also ``-win``) holds ONE key line
issued by the naive bot session for a synthetic test person (it expires by itself). Nothing here prints or logs the line:
tests assert on shapes and results only. Without the file the dependent tests skip, which is an honest "unproven".
"""
from __future__ import annotations
import os
import unittest
from pathlib import Path
_CANDIDATES = (
Path.home() / ".config" / "kvn-test-naive-key",
Path.home() / ".config" / "kvn-test-naive-key-win",
)
def key_path() -> Path | None:
override = os.environ.get("KVN_TEST_NAIVE_KEY")
if override:
return Path(override)
return next((path for path in _CANDIDATES if path.is_file()), None)
def available() -> bool:
path = key_path()
return path is not None and path.is_file()
def key_line() -> str:
path = key_path()
if path is None:
raise unittest.SkipTest("no real NaiveProxy test key here (KVN_TEST_NAIVE_KEY or ~/.config/kvn-test-naive-key)")
return path.read_text(encoding="utf-8").strip()
requires_real_key = unittest.skipUnless(available(), "no real NaiveProxy test key here")