Refactor code structure and optimize performance across multiple modules
This commit is contained in:
@@ -6,6 +6,8 @@ using Microsoft.Extensions.Logging.Abstractions;
|
||||
using StellaOps.Cli.Services;
|
||||
using StellaOps.Cli.Services.Models;
|
||||
|
||||
|
||||
using StellaOps.TestKit;
|
||||
namespace StellaOps.Cli.Tests;
|
||||
|
||||
public sealed class AttestationBundleVerifierTests : IDisposable
|
||||
@@ -29,7 +31,8 @@ public sealed class AttestationBundleVerifierTests : IDisposable
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public async Task VerifyAsync_FileNotFound_ReturnsFileNotFoundCode()
|
||||
{
|
||||
var options = new AttestationBundleVerifyOptions(
|
||||
@@ -42,7 +45,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 +60,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 +77,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 +92,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 +106,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 +122,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 +139,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 +156,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 +170,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 +189,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 +207,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();
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
<ProjectReference Include="../../__Libraries/StellaOps.Cli.Plugins.NonCore/StellaOps.Cli.Plugins.NonCore.csproj" />
|
||||
<ProjectReference Include="../../../__Libraries/StellaOps.Configuration/StellaOps.Configuration.csproj" />
|
||||
<ProjectReference Include="../../../__Libraries/StellaOps.Infrastructure.Postgres/StellaOps.Infrastructure.Postgres.csproj" />
|
||||
<ProjectReference Include="../../../__Libraries/StellaOps.TestKit/StellaOps.TestKit.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
namespace StellaOps.Cli.Tests;
|
||||
using StellaOps.TestKit;
|
||||
namespace StellaOps.Cli.Tests;
|
||||
|
||||
public class UnitTest1
|
||||
{
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public void Test1()
|
||||
{
|
||||
|
||||
|
||||
Reference in New Issue
Block a user