fix: unify PIN hashing across CLI, FSM, and web (closes #2) #7

Merged
alee merged 16 commits from fix/issue-2-pin-unification into main 2026-04-05 16:59:51 +00:00
2 changed files with 23 additions and 1 deletions
Showing only changes of commit e6069a68fc - Show all commits

View File

@@ -562,3 +562,25 @@ class TestArmRequestDispatch:
) )
assert calls == [] assert calls == []
def test_arm_request_default_triggered_by(self, test_db):
"""Omitting triggered_by must default to 'unknown' (audit-log value)."""
from vigilar.events.processor import EventProcessor
processor = EventProcessor.__new__(EventProcessor)
calls = []
class FakeFSM:
state = ArmState.DISARMED
def transition(self, new_state, pin="", triggered_by="system"):
calls.append((new_state, pin, triggered_by))
return True
processor._handle_arm_request(
payload={"mode": "DISARMED", "pin": ""},
fsm=FakeFSM(),
)
assert len(calls) == 1
assert calls[0][2] == "unknown"

View File

@@ -171,7 +171,7 @@ class EventProcessor:
def _handle_arm_request( def _handle_arm_request(
self, self,
payload: dict[str, Any], payload: dict[str, Any],
fsm: "ArmStateFSM", fsm: ArmStateFSM,
) -> None: ) -> None:
"""Handle an arm/disarm request received over MQTT. """Handle an arm/disarm request received over MQTT.