Refactor code structure and optimize performance across multiple modules
This commit is contained in:
@@ -3,11 +3,13 @@ using StellaOps.TaskRunner.Core.Attestation;
|
||||
using StellaOps.TaskRunner.Core.Events;
|
||||
using StellaOps.TaskRunner.Core.Evidence;
|
||||
|
||||
using StellaOps.TestKit;
|
||||
namespace StellaOps.TaskRunner.Tests;
|
||||
|
||||
public sealed class PackRunAttestationTests
|
||||
{
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public async Task GenerateAsync_CreatesAttestationWithSubjects()
|
||||
{
|
||||
var store = new InMemoryPackRunAttestationStore();
|
||||
@@ -45,7 +47,8 @@ public sealed class PackRunAttestationTests
|
||||
Assert.NotNull(result.Attestation.Envelope);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public async Task GenerateAsync_WithoutSigner_CreatesPendingAttestation()
|
||||
{
|
||||
var store = new InMemoryPackRunAttestationStore();
|
||||
@@ -79,7 +82,8 @@ public sealed class PackRunAttestationTests
|
||||
Assert.Null(result.Attestation.Envelope);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public async Task GenerateAsync_EmitsTimelineEvent()
|
||||
{
|
||||
var store = new InMemoryPackRunAttestationStore();
|
||||
@@ -115,7 +119,8 @@ public sealed class PackRunAttestationTests
|
||||
Assert.Equal(PackRunAttestationEventTypes.AttestationCreated, evt.EventType);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public async Task VerifyAsync_ValidatesSubjectsMatch()
|
||||
{
|
||||
var store = new InMemoryPackRunAttestationStore();
|
||||
@@ -161,7 +166,8 @@ public sealed class PackRunAttestationTests
|
||||
Assert.Equal(PackRunRevocationStatus.NotRevoked, verifyResult.RevocationStatus);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public async Task VerifyAsync_DetectsMismatchedSubjects()
|
||||
{
|
||||
var store = new InMemoryPackRunAttestationStore();
|
||||
@@ -213,7 +219,8 @@ public sealed class PackRunAttestationTests
|
||||
Assert.Contains(verifyResult.Errors, e => e.Contains("Missing subjects"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public async Task VerifyAsync_DetectsRevokedAttestation()
|
||||
{
|
||||
var store = new InMemoryPackRunAttestationStore();
|
||||
@@ -264,7 +271,8 @@ public sealed class PackRunAttestationTests
|
||||
Assert.Equal(PackRunRevocationStatus.Revoked, verifyResult.RevocationStatus);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public async Task VerifyAsync_ReturnsErrorForNonExistentAttestation()
|
||||
{
|
||||
var store = new InMemoryPackRunAttestationStore();
|
||||
@@ -286,7 +294,8 @@ public sealed class PackRunAttestationTests
|
||||
Assert.Contains(verifyResult.Errors, e => e.Contains("not found"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public async Task ListByRunAsync_ReturnsAttestationsForRun()
|
||||
{
|
||||
var store = new InMemoryPackRunAttestationStore();
|
||||
@@ -321,7 +330,8 @@ public sealed class PackRunAttestationTests
|
||||
Assert.All(attestations, a => Assert.Equal("run-007", a.RunId));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public async Task GetEnvelopeAsync_ReturnsEnvelopeForSignedAttestation()
|
||||
{
|
||||
var store = new InMemoryPackRunAttestationStore();
|
||||
@@ -354,7 +364,8 @@ public sealed class PackRunAttestationTests
|
||||
Assert.Single(envelope.Signatures);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public void PackRunAttestationSubject_FromArtifact_ParsesSha256Prefix()
|
||||
{
|
||||
var artifact = new PackRunArtifactReference(
|
||||
@@ -369,7 +380,8 @@ public sealed class PackRunAttestationTests
|
||||
Assert.Equal("abcdef123456", subject.Digest["sha256"]);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public void PackRunAttestation_ComputeStatementDigest_IsDeterministic()
|
||||
{
|
||||
var subjects = new List<PackRunAttestationSubject>
|
||||
@@ -399,7 +411,8 @@ public sealed class PackRunAttestationTests
|
||||
Assert.StartsWith("sha256:", digest1);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public void PackRunDsseEnvelope_ComputeDigest_IsDeterministic()
|
||||
{
|
||||
var envelope = new PackRunDsseEnvelope(
|
||||
@@ -414,7 +427,8 @@ public sealed class PackRunAttestationTests
|
||||
Assert.StartsWith("sha256:", digest1);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public async Task GenerateAsync_WithExternalParameters_IncludesInPredicate()
|
||||
{
|
||||
var store = new InMemoryPackRunAttestationStore();
|
||||
@@ -450,7 +464,8 @@ public sealed class PackRunAttestationTests
|
||||
Assert.Contains("manifestUrl", result.Attestation.PredicateJson);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public async Task GenerateAsync_WithResolvedDependencies_IncludesInPredicate()
|
||||
{
|
||||
var store = new InMemoryPackRunAttestationStore();
|
||||
|
||||
Reference in New Issue
Block a user