tests: feed WebServerFixture a Smtp config so Authenticate fires
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).
This commit is contained in:
parent
87e824fa63
commit
4566223a2c
1 changed files with 8 additions and 1 deletions
|
|
@ -137,7 +137,14 @@ namespace Yavsc.Org.Tests
|
||||||
|
|
||||||
builder.AddConfiguration(null).AddInMemoryCollection(new Dictionary<string, string?>
|
builder.AddConfiguration(null).AddInMemoryCollection(new Dictionary<string, string?>
|
||||||
{
|
{
|
||||||
[$"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
|
// Configure Kestrel for HTTPS with self-signed certificate on a dynamic port
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue