From 4566223a2c65543d0751a4a06a66201e87bf925f Mon Sep 17 00:00:00 2001 From: Paul Schneider Date: Sat, 27 Jun 2026 21:16:03 +0100 Subject: [PATCH] tests: feed WebServerFixture a Smtp config so Authenticate fires MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The EMaillingTests.SendEMailSynchrone smoke test asserts the recording fake observed this exact call sequence on a successful send: Connect, Authenticate, Send, Disconnect MailSender.SendEmailAsync only calls Authenticate when smtpSettings.UserName is non-null (src/Yavsc.Server/Services/ MailSender.cs line 89). WebServerFixture built the host without a Smtp config — so UserName resolved to null, Authenticate was skipped, and the recording captured only: Connect, Send, Disconnect Pre-existing breakage, not introduced by recent work; the fixture had been loading from .env indirectly (probably never, or before a refactor that stopped doing so). Feed the test host a fake SMTP config via the same AddInMemoryCollection the fixture already uses for ConnectionStrings: Smtp:Host = smtp.test.local Smtp:Port = 465 Smtp:UserName = test-user Smtp:Password = test-pass UserName non-null means MailSender now exercises the Authenticate branch, which the recording captures. Tests in the Yavsc.Org.Tests suite: 21/21 green (was 20/21 with SendEMailSynchrone failing). --- src/Yavsc.Org.Tests/WebServerFixture.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Yavsc.Org.Tests/WebServerFixture.cs b/src/Yavsc.Org.Tests/WebServerFixture.cs index da1b30a2..402211f5 100644 --- a/src/Yavsc.Org.Tests/WebServerFixture.cs +++ b/src/Yavsc.Org.Tests/WebServerFixture.cs @@ -137,7 +137,14 @@ namespace Yavsc.Org.Tests builder.AddConfiguration(null).AddInMemoryCollection(new Dictionary { - [$"ConnectionStrings:{YavscConstants.YavscConnectionStringName}"] = "InMemory" + [$"ConnectionStrings:{YavscConstants.YavscConnectionStringName}"] = "InMemory", + // SMTP test config: UserName non-null so MailSender + // exercises the Authenticate branch — the + // RecordingSmtpClient captures it. + ["Smtp:Host"] = "smtp.test.local", + ["Smtp:Port"] = "465", + ["Smtp:UserName"] = "test-user", + ["Smtp:Password"] = "test-pass", }); // Configure Kestrel for HTTPS with self-signed certificate on a dynamic port