Initialize git, add Apache-2.0 LICENSE, .gitattributes (LF line endings), AGENTS.md (entry points, stack, discovery order, baseline checks), RUNBOOK.md (dev boot, prod deploy with overlay, ingestion, failures, rollback, scaling notes), .env.prod.example with rotated credential placeholders, and dev-only warnings on .env.example. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
27 lines
764 B
Python
27 lines
764 B
Python
from __future__ import annotations
|
|
|
|
import hashlib
|
|
from pathlib import Path
|
|
|
|
from app.utils.hashing import sha256_bytes, sha256_file
|
|
|
|
|
|
def test_sha256_bytes_matches_hashlib():
|
|
data = b"legacyhub" * 1000
|
|
assert sha256_bytes(data) == hashlib.sha256(data).hexdigest()
|
|
|
|
|
|
def test_sha256_file_streaming_matches_hashlib(tmp_path: Path):
|
|
payload = b"\x01\x02\x03" * 5_000_000 # 15 MiB - exercises chunking
|
|
target = tmp_path / "blob.bin"
|
|
target.write_bytes(payload)
|
|
assert sha256_file(target) == hashlib.sha256(payload).hexdigest()
|
|
|
|
|
|
def test_sha256_file_distinguishes_content(tmp_path: Path):
|
|
a = tmp_path / "a.bin"
|
|
b = tmp_path / "b.bin"
|
|
a.write_bytes(b"alpha")
|
|
b.write_bytes(b"beta")
|
|
assert sha256_file(a) != sha256_file(b)
|