feat(campaign): govern attachment reuse
This commit is contained in:
@@ -16,8 +16,10 @@ from govoplan_campaign.backend.persistence.campaigns import (
|
||||
_verify_storage_keys_absent,
|
||||
)
|
||||
from govoplan_campaign.backend.routes.versions import (
|
||||
_attachment_reuse_audit_evidence,
|
||||
_campaign_build_recovery_plan,
|
||||
_residual_file_audit_evidence,
|
||||
_review_decision_audit_evidence,
|
||||
)
|
||||
|
||||
|
||||
@@ -56,6 +58,49 @@ def test_residual_file_audit_evidence_omits_recipient_identity() -> None:
|
||||
}
|
||||
|
||||
|
||||
def test_attachment_reuse_audit_evidence_keeps_policy_but_not_file_names() -> None:
|
||||
assert _attachment_reuse_audit_evidence({
|
||||
"contract_version": "1",
|
||||
"policy": {"action": "review", "allow_within": "same_recipient"},
|
||||
"duplicate_file_count": 4,
|
||||
"allowed_file_count": 1,
|
||||
"violation_file_count": 3,
|
||||
"affected_message_count": 5,
|
||||
"findings": [{"file_name": "personal.pdf"}],
|
||||
}) == {
|
||||
"contract_version": "1",
|
||||
"policy": {"action": "review", "allow_within": "same_recipient"},
|
||||
"duplicate_file_count": 4,
|
||||
"allowed_file_count": 1,
|
||||
"violation_file_count": 3,
|
||||
"affected_message_count": 5,
|
||||
}
|
||||
|
||||
|
||||
def test_review_decision_audit_evidence_is_aggregate_and_integrity_sealed() -> None:
|
||||
version = type("Version", (), {
|
||||
"editor_state": {
|
||||
"review_send": {
|
||||
"issue_decisions": [{
|
||||
"decision": "accept",
|
||||
"reason": "Approved exception",
|
||||
"issue_codes": ["duplicate_attachment_reuse"],
|
||||
"issue_fingerprint": "f" * 64,
|
||||
"message_sha256": "m" * 64,
|
||||
}]
|
||||
}
|
||||
}
|
||||
})()
|
||||
|
||||
evidence = _review_decision_audit_evidence(version)
|
||||
|
||||
assert evidence["count"] == 1
|
||||
assert evidence["with_reason_count"] == 1
|
||||
assert evidence["issue_codes"] == ["duplicate_attachment_reuse"]
|
||||
assert len(str(evidence["evidence_sha256"])) == 64
|
||||
assert "Approved exception" not in str(evidence)
|
||||
|
||||
|
||||
def test_generated_object_manifest_verifies_exact_bytes(tmp_path: Path) -> None:
|
||||
storage = LocalFilesystemStorageBackend(tmp_path)
|
||||
payload = b"Message-ID: <build@example.test>\r\n\r\nbody"
|
||||
|
||||
Reference in New Issue
Block a user