2dd5e318d7
Allow Web SMTP egress on TCP 587 and reuse the saved channel password only when connection settings match. Ref: IT-1601
35 lines
1.5 KiB
C#
35 lines
1.5 KiB
C#
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);
|
|
}
|
|
}
|