security: harden Campaign delivery effects and reconciliation
This commit is contained in:
@@ -40,7 +40,7 @@ def _job() -> SimpleNamespace:
|
||||
eml_storage_key="campaign/job-1.eml",
|
||||
claim_token="job-claim-secret",
|
||||
attempt_count=1,
|
||||
last_error=None,
|
||||
last_error="smtp.internal.example /srv/private provider-secret",
|
||||
queued_at=_now(),
|
||||
claimed_at=_now(),
|
||||
smtp_started_at=_now(),
|
||||
@@ -67,9 +67,9 @@ def _smtp_attempt() -> SimpleNamespace:
|
||||
status="started",
|
||||
claim_token="attempt-claim-secret",
|
||||
smtp_status_code=None,
|
||||
smtp_response=None,
|
||||
error_type=None,
|
||||
error_message=None,
|
||||
smtp_response="smtp.internal.example provider-secret",
|
||||
error_type="/srv/private/ProviderError",
|
||||
error_message="credential=provider-secret",
|
||||
started_at=_now(),
|
||||
finished_at=None,
|
||||
)
|
||||
@@ -82,7 +82,7 @@ def _imap_attempt() -> SimpleNamespace:
|
||||
status="claimed",
|
||||
claim_token="imap-claim-secret",
|
||||
folder="Sent",
|
||||
error_message=None,
|
||||
error_message="imap.internal.example /srv/private provider-secret",
|
||||
created_at=_now(),
|
||||
updated_at=_now(),
|
||||
)
|
||||
@@ -148,6 +148,7 @@ def test_version_response_omits_source_base_path_and_sanitizes_summaries() -> No
|
||||
"campaign": {"title": "Public"},
|
||||
"files": [{"storage_key": "private/object", "filename": "public.pdf"}],
|
||||
"server": {
|
||||
"mail_profile_id": "profile-1",
|
||||
"smtp": {"host": "smtp.example.invalid", "password": "smtp-secret"},
|
||||
"imap": {"host": "imap.example.invalid", "password": "imap-secret"},
|
||||
"credentials": {
|
||||
@@ -176,14 +177,7 @@ def test_version_response_omits_source_base_path_and_sanitizes_summaries() -> No
|
||||
assert detail["raw_json"] == {
|
||||
"campaign": {"title": "Public"},
|
||||
"files": [{"filename": "public.pdf"}],
|
||||
"server": {
|
||||
"smtp": {"host": "smtp.example.invalid"},
|
||||
"imap": {"host": "imap.example.invalid"},
|
||||
"credentials": {
|
||||
"smtp": {"username": "sender"},
|
||||
"imap": {"username": "archive"},
|
||||
},
|
||||
},
|
||||
"server": {"mail_profile_id": "profile-1"},
|
||||
"archives": [{"password": "business-zip-password"}],
|
||||
"template": {
|
||||
"source": {
|
||||
@@ -209,6 +203,14 @@ def test_ordinary_job_detail_and_attempts_do_not_expose_diagnostics() -> None:
|
||||
assert job_payload["attachments"] == [{"filename": "public.pdf"}]
|
||||
assert "claim_token" not in attempts["smtp"][0]
|
||||
assert "claim_token" not in attempts["imap"][0]
|
||||
assert "smtp_response" not in attempts["smtp"][0]
|
||||
assert "error_type" not in attempts["smtp"][0]
|
||||
assert "error_message" not in attempts["smtp"][0]
|
||||
assert "error_message" not in attempts["imap"][0]
|
||||
ordinary = repr({"job": job_payload, "attempts": attempts})
|
||||
assert "internal.example" not in ordinary
|
||||
assert "/srv/private" not in ordinary
|
||||
assert "provider-secret" not in ordinary
|
||||
|
||||
|
||||
def test_operator_diagnostics_include_claim_and_storage_details() -> None:
|
||||
@@ -223,6 +225,9 @@ def test_operator_diagnostics_include_claim_and_storage_details() -> None:
|
||||
assert diagnostics["worker_claim"]["claim_token"] == "job-claim-secret"
|
||||
assert diagnostics["attempts"]["smtp"][0]["claim_token"] == "attempt-claim-secret"
|
||||
assert diagnostics["attempts"]["imap"][0]["claim_token"] == "imap-claim-secret"
|
||||
assert "smtp.internal.example" in diagnostics["attempts"]["smtp"][0]["smtp_response"]
|
||||
assert "imap.internal.example" in diagnostics["attempts"]["imap"][0]["error_message"]
|
||||
assert "provider-secret" in diagnostics["worker_claim"]["last_error"]
|
||||
|
||||
|
||||
def test_diagnostics_permission_is_operator_only_by_default() -> None:
|
||||
|
||||
Reference in New Issue
Block a user