Refactor code structure and optimize performance across multiple modules
This commit is contained in:
@@ -6,13 +6,15 @@ using StellaOps.Notify.Engine;
|
||||
using StellaOps.Notify.Models;
|
||||
using Xunit;
|
||||
|
||||
using StellaOps.TestKit;
|
||||
namespace StellaOps.Notify.Connectors.Slack.Tests;
|
||||
|
||||
public sealed class SlackChannelHealthProviderTests
|
||||
{
|
||||
private static readonly SlackChannelHealthProvider Provider = new();
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public async Task CheckAsync_ReturnsHealthy()
|
||||
{
|
||||
var channel = CreateChannel(enabled: true, target: "#sec-ops");
|
||||
@@ -33,7 +35,8 @@ public sealed class SlackChannelHealthProviderTests
|
||||
Assert.Equal(ComputeSecretHash(channel.Config.SecretRef), result.Metadata["slack.secretRef.hash"]);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public async Task CheckAsync_ReturnsDegradedWhenDisabled()
|
||||
{
|
||||
var channel = CreateChannel(enabled: false, target: "#sec-ops");
|
||||
@@ -51,7 +54,8 @@ public sealed class SlackChannelHealthProviderTests
|
||||
Assert.Equal("false", result.Metadata["slack.channel.enabled"]);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public async Task CheckAsync_ReturnsUnhealthyWhenTargetMissing()
|
||||
{
|
||||
var channel = CreateChannel(enabled: true, target: null);
|
||||
|
||||
@@ -22,7 +22,8 @@ public sealed class SlackChannelTestProviderTests
|
||||
Metadata: new Dictionary<string, string>(),
|
||||
Attachments: new List<string>());
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public async Task BuildPreviewAsync_ProducesDeterministicMetadata()
|
||||
{
|
||||
var provider = new SlackChannelTestProvider();
|
||||
@@ -64,7 +65,8 @@ public sealed class SlackChannelTestProviderTests
|
||||
Assert.Equal(ComputeSecretHash(channel.Config.SecretRef), result.Metadata["slack.secretRef.hash"]);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public async Task BuildPreviewAsync_RedactsSensitiveProperties()
|
||||
{
|
||||
var provider = new SlackChannelTestProvider();
|
||||
@@ -106,6 +108,7 @@ public sealed class SlackChannelTestProviderTests
|
||||
private static string ComputeSecretHash(string secretRef)
|
||||
{
|
||||
using var sha = System.Security.Cryptography.SHA256.Create();
|
||||
using StellaOps.TestKit;
|
||||
var bytes = System.Text.Encoding.UTF8.GetBytes(secretRef.Trim());
|
||||
var hash = sha.ComputeHash(bytes);
|
||||
return System.Convert.ToHexString(hash, 0, 8).ToLowerInvariant();
|
||||
|
||||
Reference in New Issue
Block a user