Refactor code structure and optimize performance across multiple modules
This commit is contained in:
@@ -16,6 +16,7 @@ using StellaOps.Scanner.Reachability;
|
||||
using StellaOps.Scanner.ReachabilityDrift.Attestation;
|
||||
using Xunit;
|
||||
|
||||
using StellaOps.TestKit;
|
||||
namespace StellaOps.Scanner.ReachabilityDrift.Tests;
|
||||
|
||||
public sealed class DriftAttestationServiceTests
|
||||
@@ -32,7 +33,8 @@ public sealed class DriftAttestationServiceTests
|
||||
_optionsMock.Setup(x => x.CurrentValue).Returns(_options);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public async Task CreateAttestationAsync_Creates_Valid_Attestation()
|
||||
{
|
||||
// Arrange
|
||||
@@ -50,7 +52,8 @@ public sealed class DriftAttestationServiceTests
|
||||
result.CreatedAt.Should().Be(_timeProvider.GetUtcNow());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public async Task CreateAttestationAsync_Returns_Failure_When_Disabled()
|
||||
{
|
||||
// Arrange
|
||||
@@ -66,7 +69,8 @@ public sealed class DriftAttestationServiceTests
|
||||
result.Error.Should().Contain("disabled");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public async Task CreateAttestationAsync_Throws_When_Request_Null()
|
||||
{
|
||||
// Arrange
|
||||
@@ -77,7 +81,8 @@ public sealed class DriftAttestationServiceTests
|
||||
() => service.CreateAttestationAsync(null!));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public async Task CreateAttestationAsync_Envelope_Contains_Correct_PayloadType()
|
||||
{
|
||||
// Arrange
|
||||
@@ -91,7 +96,8 @@ public sealed class DriftAttestationServiceTests
|
||||
result.EnvelopeJson.Should().Contain("application/vnd.in-toto+json");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public async Task CreateAttestationAsync_Envelope_Contains_Signature()
|
||||
{
|
||||
// Arrange
|
||||
@@ -109,7 +115,8 @@ public sealed class DriftAttestationServiceTests
|
||||
signatures[0].GetProperty("sig").GetString().Should().NotBeNullOrEmpty();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public async Task CreateAttestationAsync_Statement_Contains_Predicate()
|
||||
{
|
||||
// Arrange
|
||||
@@ -129,7 +136,8 @@ public sealed class DriftAttestationServiceTests
|
||||
.Should().Be("stellaops.dev/predicates/reachability-drift@v1");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public async Task CreateAttestationAsync_Predicate_Contains_Drift_Summary()
|
||||
{
|
||||
// Arrange
|
||||
@@ -146,7 +154,8 @@ public sealed class DriftAttestationServiceTests
|
||||
predicate.GetProperty("drift").GetProperty("newlyUnreachableCount").GetInt32().Should().Be(0);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public async Task CreateAttestationAsync_Predicate_Contains_Image_References()
|
||||
{
|
||||
// Arrange
|
||||
@@ -169,7 +178,8 @@ public sealed class DriftAttestationServiceTests
|
||||
.Should().Be("sha256:head456");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public async Task CreateAttestationAsync_Predicate_Contains_Analysis_Metadata()
|
||||
{
|
||||
// Arrange
|
||||
@@ -188,7 +198,8 @@ public sealed class DriftAttestationServiceTests
|
||||
analysis.GetProperty("scanner").GetProperty("name").GetString().Should().Be("StellaOps.Scanner");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public async Task CreateAttestationAsync_Produces_Deterministic_Digest_For_Same_Input()
|
||||
{
|
||||
// Arrange
|
||||
@@ -203,7 +214,8 @@ public sealed class DriftAttestationServiceTests
|
||||
result1.AttestationDigest.Should().Be(result2.AttestationDigest);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public async Task CreateAttestationAsync_With_Signer_Service_Calls_SignAsync()
|
||||
{
|
||||
// Arrange
|
||||
@@ -231,7 +243,8 @@ public sealed class DriftAttestationServiceTests
|
||||
It.IsAny<CancellationToken>()), Times.Once);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public async Task CreateAttestationAsync_Returns_Failure_When_Signer_Fails()
|
||||
{
|
||||
// Arrange
|
||||
|
||||
Reference in New Issue
Block a user