Refactor code structure and optimize performance across multiple modules

This commit is contained in:
StellaOps Bot
2025-12-26 20:03:22 +02:00
parent c786faae84
commit f10d83c444
1385 changed files with 69732 additions and 10280 deletions

View File

@@ -29,7 +29,8 @@ public sealed class AttestationBundleVerifierTests : IDisposable
}
}
[Fact]
[Trait("Category", TestCategories.Unit)]
[Fact]
public async Task VerifyAsync_FileNotFound_ReturnsFileNotFoundCode()
{
var options = new AttestationBundleVerifyOptions(
@@ -42,7 +43,8 @@ public sealed class AttestationBundleVerifierTests : IDisposable
Assert.Equal(AttestationBundleExitCodes.FileNotFound, result.ExitCode);
}
[Fact]
[Trait("Category", TestCategories.Unit)]
[Fact]
public async Task VerifyAsync_ValidBundle_ReturnsSuccess()
{
var bundlePath = await CreateValidBundleAsync();
@@ -56,7 +58,8 @@ public sealed class AttestationBundleVerifierTests : IDisposable
Assert.Equal("verified", result.Status);
}
[Fact]
[Trait("Category", TestCategories.Unit)]
[Fact]
public async Task VerifyAsync_ValidBundle_ReturnsMetadata()
{
var bundlePath = await CreateValidBundleAsync();
@@ -72,7 +75,8 @@ public sealed class AttestationBundleVerifierTests : IDisposable
Assert.StartsWith("sha256:", result.RootHash);
}
[Fact]
[Trait("Category", TestCategories.Unit)]
[Fact]
public async Task VerifyAsync_CorruptedArchive_ReturnsFormatError()
{
var bundlePath = Path.Combine(_tempDir, "corrupted.tgz");
@@ -86,7 +90,8 @@ public sealed class AttestationBundleVerifierTests : IDisposable
Assert.Equal(AttestationBundleExitCodes.FormatError, result.ExitCode);
}
[Fact]
[Trait("Category", TestCategories.Unit)]
[Fact]
public async Task VerifyAsync_ChecksumMismatch_ReturnsChecksumMismatchCode()
{
var bundlePath = await CreateBundleWithBadChecksumAsync();
@@ -99,7 +104,8 @@ public sealed class AttestationBundleVerifierTests : IDisposable
Assert.Equal(AttestationBundleExitCodes.ChecksumMismatch, result.ExitCode);
}
[Fact]
[Trait("Category", TestCategories.Unit)]
[Fact]
public async Task VerifyAsync_ExternalChecksumMismatch_ReturnsChecksumMismatchCode()
{
var bundlePath = await CreateValidBundleAsync();
@@ -114,7 +120,8 @@ public sealed class AttestationBundleVerifierTests : IDisposable
Assert.Equal(AttestationBundleExitCodes.ChecksumMismatch, result.ExitCode);
}
[Fact]
[Trait("Category", TestCategories.Unit)]
[Fact]
public async Task VerifyAsync_MissingTransparency_WhenNotOffline_ReturnsMissingTransparencyCode()
{
var bundlePath = await CreateBundleWithoutTransparencyAsync();
@@ -130,7 +137,8 @@ public sealed class AttestationBundleVerifierTests : IDisposable
Assert.Equal(AttestationBundleExitCodes.MissingTransparency, result.ExitCode);
}
[Fact]
[Trait("Category", TestCategories.Unit)]
[Fact]
public async Task VerifyAsync_MissingTransparency_WhenOffline_ReturnsSuccess()
{
var bundlePath = await CreateBundleWithoutTransparencyAsync();
@@ -146,7 +154,8 @@ public sealed class AttestationBundleVerifierTests : IDisposable
Assert.Equal(AttestationBundleExitCodes.Success, result.ExitCode);
}
[Fact]
[Trait("Category", TestCategories.Unit)]
[Fact]
public async Task VerifyAsync_MissingDssePayload_ReturnsSignatureFailure()
{
var bundlePath = await CreateBundleWithMissingDssePayloadAsync();
@@ -159,7 +168,8 @@ public sealed class AttestationBundleVerifierTests : IDisposable
Assert.Equal(AttestationBundleExitCodes.SignatureFailure, result.ExitCode);
}
[Fact]
[Trait("Category", TestCategories.Unit)]
[Fact]
public async Task ImportAsync_ValidBundle_ReturnsSuccess()
{
var bundlePath = await CreateValidBundleAsync();
@@ -177,7 +187,8 @@ public sealed class AttestationBundleVerifierTests : IDisposable
Assert.Equal("imported", result.Status);
}
[Fact]
[Trait("Category", TestCategories.Unit)]
[Fact]
public async Task ImportAsync_InvalidBundle_ReturnsVerificationFailed()
{
var bundlePath = Path.Combine(_tempDir, "invalid.tgz");
@@ -194,7 +205,8 @@ public sealed class AttestationBundleVerifierTests : IDisposable
Assert.Equal("verification_failed", result.Status);
}
[Fact]
[Trait("Category", TestCategories.Unit)]
[Fact]
public async Task ImportAsync_InheritsTenantFromMetadata()
{
var bundlePath = await CreateValidBundleAsync();
@@ -390,6 +402,7 @@ public sealed class AttestationBundleVerifierTests : IDisposable
{
var bytes = Encoding.UTF8.GetBytes(content);
using var dataStream = new MemoryStream(bytes);
using StellaOps.TestKit;
var entry = new PaxTarEntry(TarEntryType.RegularFile, name)
{
DataStream = dataStream

View File

@@ -11,6 +11,7 @@ using Xunit;
using StellaOps.Cli.Commands;
using StellaOps.Cryptography;
using StellaOps.TestKit;
namespace StellaOps.Cli.Tests;
/// <summary>
@@ -19,7 +20,8 @@ namespace StellaOps.Cli.Tests;
/// </summary>
public class CryptoCommandTests
{
[Fact]
[Trait("Category", TestCategories.Unit)]
[Fact]
public void CryptoCommand_ShouldHaveExpectedSubcommands()
{
// Arrange
@@ -40,7 +42,8 @@ public class CryptoCommandTests
Assert.Contains(command.Children, c => c.Name == "profiles");
}
[Fact]
[Trait("Category", TestCategories.Unit)]
[Fact]
public void CryptoSignCommand_ShouldRequireInputOption()
{
// Arrange
@@ -61,7 +64,8 @@ public class CryptoCommandTests
Assert.Contains(result.Errors, e => e.Message.Contains("--input"));
}
[Fact]
[Trait("Category", TestCategories.Unit)]
[Fact]
public void CryptoVerifyCommand_ShouldRequireInputOption()
{
// Arrange
@@ -82,7 +86,8 @@ public class CryptoCommandTests
Assert.Contains(result.Errors, e => e.Message.Contains("--input"));
}
[Fact]
[Trait("Category", TestCategories.Unit)]
[Fact]
public void CryptoProfilesCommand_ShouldAcceptDetailsOption()
{
// Arrange
@@ -102,7 +107,8 @@ public class CryptoCommandTests
Assert.Empty(result.Errors);
}
[Fact]
[Trait("Category", TestCategories.Unit)]
[Fact]
public async Task CryptoSignCommand_WithMissingFile_ShouldReturnError()
{
// Arrange
@@ -138,7 +144,8 @@ public class CryptoCommandTests
Assert.Contains("not found", output, StringComparison.OrdinalIgnoreCase);
}
[Fact]
[Trait("Category", TestCategories.Unit)]
[Fact]
public async Task CryptoProfilesCommand_WithNoCryptoProviders_ShouldReturnError()
{
// Arrange
@@ -172,7 +179,8 @@ public class CryptoCommandTests
Assert.Contains("No crypto providers available", output, StringComparison.OrdinalIgnoreCase);
}
[Fact]
[Trait("Category", TestCategories.Unit)]
[Fact]
public async Task CryptoProfilesCommand_WithCryptoProviders_ShouldListThem()
{
// Arrange
@@ -207,7 +215,8 @@ public class CryptoCommandTests
}
#if STELLAOPS_ENABLE_GOST
[Fact]
[Trait("Category", TestCategories.Unit)]
[Fact]
public void WithGostEnabled_ShouldShowGostInDistributionInfo()
{
// This test only runs when GOST is enabled at build time
@@ -217,7 +226,8 @@ public class CryptoCommandTests
#endif
#if STELLAOPS_ENABLE_EIDAS
[Fact]
[Trait("Category", TestCategories.Unit)]
[Fact]
public void WithEidasEnabled_ShouldShowEidasInDistributionInfo()
{
// This test only runs when eIDAS is enabled at build time
@@ -226,7 +236,8 @@ public class CryptoCommandTests
#endif
#if STELLAOPS_ENABLE_SM
[Fact]
[Trait("Category", TestCategories.Unit)]
[Fact]
public void WithSmEnabled_ShouldShowSmInDistributionInfo()
{
// This test only runs when SM is enabled at build time

View File

@@ -2,7 +2,8 @@
public class UnitTest1
{
[Fact]
[Trait("Category", TestCategories.Unit)]
[Fact]
public void Test1()
{