websecure / hackathon-techex /tests /test_verify.py
SoulInPsyAbstract's picture
Mirror GitHub commit 954b20931bd23bf971072a5ec79424ac03b09d6b (committed 2026-09-12T11:35:28+03:00), pushed 2026-09-12T08:35:36Z
7cfea77 verified
Raw
History Blame Contribute Delete
1.01 kB
import json
from sipa_scan_ledger.chain import ScanLedger
from sipa_scan_ledger.record import Finding, ScanRecord
from sipa_scan_ledger.verify import verify
def _populate(path):
log = ScanLedger(path)
log.append(ScanRecord("a.com", "t1", [Finding("high", "No forced HTTPS redirect")]))
log.append(ScanRecord("a.com", "t2", []))
return log
def test_clean_ledger_verifies(tmp_path):
p = tmp_path / "l.jsonl"
_populate(p)
res = verify(p)
assert res.ok
assert res.count == 2
def test_missing_file(tmp_path):
res = verify(tmp_path / "nope.jsonl")
assert not res.ok
def test_altered_entry_is_caught(tmp_path):
p = tmp_path / "l.jsonl"
_populate(p)
lines = p.read_text().splitlines()
tampered = json.loads(lines[0])
tampered["findings"] = [] # quietly erase the finding
lines[0] = json.dumps(tampered)
p.write_text("\n".join(lines) + "\n")
res = verify(p)
assert not res.ok
assert any("altered" in x for x in res.problems)