fix(notification-service): resolve NotificationService-005..009 — explicit TLS modes, per-credential token cache, timeout/throttle, address validation, credential redaction
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
namespace ScadaLink.NotificationService.Tests;
|
||||
|
||||
/// <summary>
|
||||
/// NS-005: Tests for parsing the configured SMTP TLS mode into the three-state enum.
|
||||
/// </summary>
|
||||
public class SmtpTlsModeParserTests
|
||||
{
|
||||
[Theory]
|
||||
[InlineData("none", SmtpTlsMode.None)]
|
||||
[InlineData("None", SmtpTlsMode.None)]
|
||||
[InlineData("NONE", SmtpTlsMode.None)]
|
||||
[InlineData("starttls", SmtpTlsMode.StartTls)]
|
||||
[InlineData("StartTLS", SmtpTlsMode.StartTls)]
|
||||
[InlineData("ssl", SmtpTlsMode.Ssl)]
|
||||
[InlineData("SSL", SmtpTlsMode.Ssl)]
|
||||
[InlineData(" starttls ", SmtpTlsMode.StartTls)]
|
||||
public void Parse_KnownModes_ReturnsExpected(string input, SmtpTlsMode expected)
|
||||
{
|
||||
Assert.Equal(expected, SmtpTlsModeParser.Parse(input));
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(null)]
|
||||
[InlineData("")]
|
||||
[InlineData(" ")]
|
||||
public void Parse_NullOrEmpty_DefaultsToStartTls(string? input)
|
||||
{
|
||||
Assert.Equal(SmtpTlsMode.StartTls, SmtpTlsModeParser.Parse(input));
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("auto")]
|
||||
[InlineData("tls")]
|
||||
[InlineData("implicit")]
|
||||
public void Parse_UnknownMode_Throws(string input)
|
||||
{
|
||||
// NS-005: an unknown mode must be rejected, not silently treated as Auto.
|
||||
Assert.Throws<ArgumentException>(() => SmtpTlsModeParser.Parse(input));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user