feat(slice-4): honest delivery failure — send-before-commit + 502 delivery_failed (INV-9; closes #7)
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -128,3 +128,19 @@ def test_puc_09_logout_clears_session(fresh_db_url):
|
||||
# after logout the cookie is cleared -> /me is unauthenticated again
|
||||
client.cookies.clear()
|
||||
assert client.get("/api/auth/me").status_code == 401
|
||||
|
||||
|
||||
def test_request_code_delivery_failure_is_502(fresh_db_url, monkeypatch):
|
||||
# INV-9 honest failure over HTTP (§6.4): the relay refused -> 502 delivery_failed,
|
||||
# never a fake 204. Force the app's mailer to fail after startup.
|
||||
from app.platform import mailer as mailer_mod
|
||||
|
||||
class _FailingMailer:
|
||||
def send(self, to, subject, body):
|
||||
raise mailer_mod.MailerError("relay refused")
|
||||
|
||||
with _client(fresh_db_url) as client:
|
||||
client.app.state.mailer = _FailingMailer()
|
||||
resp = client.post("/api/auth/request-code", json={"email": "merchant@example.com"})
|
||||
assert resp.status_code == 502
|
||||
assert resp.json()["error"]["code"] == "delivery_failed"
|
||||
|
||||
Reference in New Issue
Block a user