Repository navigation
feat(aspire): catch Identity email locally with MailPit - #1739
Merged
Merged
Conversation
The standalone AppHost adds a MailPit container (CommunityToolkit 17.0.0, persistent volume unless EphemeralDatabases) and references it from Web. In Development, Web sends Identity email through a MailKit SmtpEmailSender when it receives ConnectionStrings:mailpit; without it, Identity's no-op sender still applies. Any other environment fails startup if the setting is present and keeps using Mailjet unchanged. MailKit's SMTP span source and SMTP/socket meters are exported; the meters are created only when the MailPit sender is registered. Smoke tests register a user and reset a password end to end, reading each message from MailPit's API. They share JourneyFixture (fake hCaptcha) and run in their own parallel group: Web's anonymous per-IP rate limit is shared by every 127.0.0.1 client, and overlapping the browser journeys starved them.
…atch Addresses the CodeQL generic-catch-clause alert in EmailSenderStartupTests.
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
Local Identity email (registration confirmation, password reset, email change) previously went nowhere in Development. No
IEmailSenderwas registered, so Identity's no-op sender dropped every message, andRequireConfirmedEmailmeant local accounts couldn't be confirmed without editing the database. This PR catches that email in a local MailPit container and tests the flows end to end.CommunityToolkit.Aspire.Hosting.MailPit17.0.0) and references it from Web. The data volume and persistent lifetime apply only whenEphemeralDatabasesis false, the same as SQL Server and Postgres.SmtpEmailSender, built on MailKit following its documented connect → send → disconnect pattern, with plaintext and no auth because that's what MailPit accepts.ConnectionStrings:mailpitis present.ConnectionStrings:mailpitis set, so a stray setting can't divert real email away from Mailjet.Tests
SmtpEndpointTests: connection-string parsing, including rejection of non-smtpschemes, missing or invalid ports and malformed strings.EmailSenderStartupTests: which sender is chosen in Development with and without MailPit, and the startup failure outside Development.IdentityEmailSmokeTests(AppHost, containers) check the actual requirements by signing in, not by page wording:JourneyFixture(fake hCaptcha) but run in their own parallel group. Web's anonymous per-IP rate limit is shared by every127.0.0.1client, and overlapping these tests with the browser journeys used up that limit and made the journeys fail.Local results: both builds pass, Web tests 385/385, AppHost tests 31/31 (Podman).