fix(notification): enable web smtp test with saved password
Allow Web SMTP egress on TCP 587 and reuse the saved channel password only when connection settings match. Ref: IT-1601
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
using HrynCo.NotificationService.DAL.Abstract.Providers;
|
||||
using HrynCo.NotificationService.DAL.Abstract.Repositories;
|
||||
using HrynCo.NotificationService.DAL.EF;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace HrynCo.NotificationService.Web.IntegrationTests;
|
||||
|
||||
public sealed class AdminSmtpEditorViewTests(TemplateDatabaseFixture fixture) : IClassFixture<TemplateDatabaseFixture>
|
||||
{
|
||||
[Fact]
|
||||
public async Task ExistingChannelTestIncludesIdWithoutRenderingSavedPassword()
|
||||
{
|
||||
await using var context = await DefinitionApiTestContext.CreateAsync(fixture);
|
||||
using var scope = context.App.Services.CreateScope();
|
||||
var channel = new EmailChannel
|
||||
{
|
||||
ServiceName = "TestService",
|
||||
EmailChannelType = EmailChannelType.Smtp,
|
||||
Settings = new SmtpChannelSettings
|
||||
{
|
||||
Host = "smtp.example.invalid", Username = "test-user",
|
||||
Password = "saved-secret-must-not-render", FromEmail = "sender@example.invalid"
|
||||
}
|
||||
};
|
||||
await scope.ServiceProvider.GetRequiredService<IEmailChannelRepository>().AddAsync(channel);
|
||||
await scope.ServiceProvider.GetRequiredService<NotificationDbContext>().SaveChangesAsync();
|
||||
|
||||
var html = await context.Client.GetStringAsync($"/admin/channels/{channel.Id}");
|
||||
|
||||
Assert.Contains($"value=\"{channel.Id}\"", html);
|
||||
Assert.Contains("const channelId = form.querySelector('[name=\"Id\"]').value", html);
|
||||
Assert.DoesNotContain("saved-secret-must-not-render", html);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user