Files
labs-information-security/lab5-account-manager-security/tests/test_integrity_checker.py
T

18 lines
518 B
Python
Raw Normal View History

2026-07-12 14:06:45 +04:00
from pathlib import Path
from core.integrity_checker import IntegrityChecker
def test_calculate_and_verify_hash(tmp_path: Path):
file = tmp_path / "data.txt"
file.write_text("hello", encoding="utf-8")
hash_file = tmp_path / "data.hash"
checker = IntegrityChecker()
checker.save_hash(file, hash_file)
assert checker.verify_hash(file, hash_file)
# Нарушим целостность
file.write_text("changed", encoding="utf-8")
assert not checker.verify_hash(file, hash_file)