feat(common): add SMTP test-email endpoint to sanity checks - #153
Draft
geourjoa wants to merge 2 commits into
Draft
feat(common): add SMTP test-email endpoint to sanity checks#153geourjoa wants to merge 2 commits into
geourjoa wants to merge 2 commits into
Conversation
Adds POST /api/v1/management/common/sanity-checks/test-email/, a superuser-gated sibling to the sanity-checks GET endpoint, letting an admin verify SMTP delivery actually works end-to-end rather than just inspecting config. The project has no ADMINS/MANAGERS/DEFAULT_FROM_EMAIL pointing at a real inbox, so the recipient is supplied by the caller and validated as an email address. The endpoint reuses smtp_configured() to short-circuit with 400 before attempting delivery via Django's unconfigured localhost default, and the new send_test_email() service function only swallows smtplib/OSError delivery failures (reported as 502) so unrelated bugs still raise instead of being misreported as an SMTP problem. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
4 tasks
|
|
||
| result = send_test_email(recipient) | ||
| response_status = status.HTTP_200_OK if result["sent"] else status.HTTP_502_BAD_GATEWAY | ||
| return Response(result, status=response_status) |
Contributor
Author
|
Reopening to retrigger CI (initial pull_request webhook never fired for this PR). |
Contributor
Author
|
CI status note: same issue as #150 — this PR's automatic `pull_request`-triggered checks never fired despite a push with fixes and a close/reopen cycle. Manually verified green via
Recommend re-running the standard PR checks once merged into the target branch, or investigating the webhook delivery issue separately. |
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
WIP
Stacked on #151 (feat-4) — merge/rebase after that lands.
POST /api/v1/management/common/sanity-checks/test-email/, gated byIsSuperuser, short-circuits with 400 ifsmtp_configured()is false rather than attempting a doomed send.ADMINS/MANAGERS/DEFAULT_FROM_EMAILexists in settings today, so there's no fixed "send test emails here" address to default to. Worth deciding whether to add one instead long-term.send_mailfailures are caught narrowly (SMTPException,OSError), not via a bareexcept Exception, and return 502.Test plan
ruff check/ruff format/mypycleanpytest apps/common— 71 passed; email is always mocked, nothing real is ever sent in testsNo new dependencies.
WIP frontend companion PR