feat(config): deprecation warning for [system] arm_pin_hash
If a config still has the legacy [system] arm_pin_hash set but no [security] pin_hash, load_config logs a WARNING telling the operator to re-run 'vigilar config set-pin'. The legacy field is still parsed (so old configs don't fail validation) but ignored at runtime. Part of issue #2 PIN hashing unification.
This commit is contained in:
@@ -138,3 +138,22 @@ class TestCameraConfigLocation:
|
||||
from vigilar.config import CameraConfig
|
||||
cfg = CameraConfig(id="test", display_name="Test", rtsp_url="rtsp://x", location="EXTERIOR")
|
||||
assert cfg.location == "EXTERIOR"
|
||||
|
||||
|
||||
def test_deprecation_warning_for_arm_pin_hash(tmp_path, caplog):
|
||||
"""Loading a config that still uses the legacy [system] arm_pin_hash
|
||||
must log a clear warning pointing the user at `vigilar config set-pin`."""
|
||||
import logging
|
||||
cfg_path = tmp_path / "legacy.toml"
|
||||
cfg_path.write_text(
|
||||
'[system]\n'
|
||||
'arm_pin_hash = "pbkdf2_sha256$abc$def"\n'
|
||||
)
|
||||
with caplog.at_level(logging.WARNING):
|
||||
from vigilar.config import load_config
|
||||
load_config(str(cfg_path))
|
||||
|
||||
messages = [r.message for r in caplog.records if r.levelno >= logging.WARNING]
|
||||
assert any("arm_pin_hash" in m and "deprecated" in m.lower() for m in messages), (
|
||||
f"expected deprecation warning mentioning arm_pin_hash, got: {messages}"
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user