feat(cli): notification smtp update --transport smtp|ews

This commit is contained in:
Joseph Doherty
2026-08-10 06:35:33 -04:00
parent 4e633b1e64
commit 0fe1972960
2 changed files with 64 additions and 7 deletions
@@ -6,10 +6,11 @@ namespace ZB.MOM.WW.ScadaBridge.CLI.Tests.Commands;
/// <summary>
/// Tests for the <c>scadabridge notification smtp update</c> subcommand. The command
/// gained two optional flags — <c>--tls-mode</c> and <c>--credentials</c> — that plumb
/// through to <see cref="UpdateSmtpConfigCommand"/>. These tests pin that the flags
/// parse, are genuinely optional (non-breaking), and that <c>--tls-mode</c> rejects
/// values outside the canonical {None, StartTLS, SSL} set.
/// gained optional flags — <c>--tls-mode</c>, <c>--credentials</c> and <c>--transport</c> —
/// that plumb through to <see cref="UpdateSmtpConfigCommand"/>. These tests pin that the
/// flags parse, are genuinely optional (non-breaking), that <c>--tls-mode</c> rejects
/// values outside the canonical {None, StartTLS, SSL} set, and that <c>--transport</c>
/// rejects values outside {Smtp, Ews}.
/// </summary>
public class SmtpUpdateCommandTests
{
@@ -91,6 +92,46 @@ public class SmtpUpdateCommandTests
Assert.NotEmpty(parse.Errors);
}
[Fact]
public void Update_WithTransportEws_ProducesCommandCarryingIt()
{
var parse = ParseUpdate(
"--id", "1", "--server", "https://mail.example.com/ews/exchange.asmx", "--port", "443",
"--auth-mode", "Basic", "--from-address", "noreply@example.com",
"--transport", "Ews");
Assert.Empty(parse.Errors);
var cmd = NotificationCommands.BuildUpdateSmtpConfigCommand(parse);
Assert.Equal("Ews", cmd.Transport);
}
[Fact]
public void Update_WithoutTransport_ProducesCommandWithNullTransport()
{
var parse = ParseUpdate(
"--id", "2", "--server", "smtp.example.com", "--port", "25",
"--auth-mode", "Basic", "--from-address", "noreply@example.com");
Assert.Empty(parse.Errors);
var cmd = NotificationCommands.BuildUpdateSmtpConfigCommand(parse);
Assert.Null(cmd.Transport);
}
[Theory]
[InlineData("Graph")]
[InlineData("ews")] // AcceptOnlyFromAmong is case-sensitive: constrain to canonical spelling
public void Update_TransportOption_RejectsValuesOutsideCanonicalSet(string value)
{
var parse = ParseUpdate(
"--id", "1", "--server", "smtp.example.com", "--port", "587",
"--auth-mode", "Basic", "--from-address", "noreply@example.com",
"--transport", value);
Assert.NotEmpty(parse.Errors);
}
[Fact]
public void Update_TlsModeAndCredentials_AreNotRequired()
{