Refactor code structure and optimize performance across multiple modules
This commit is contained in:
@@ -14,6 +14,8 @@ using System.Text.Json;
|
||||
using FluentAssertions;
|
||||
using Xunit;
|
||||
|
||||
|
||||
using StellaOps.TestKit;
|
||||
namespace StellaOps.AirGap.Controller.Tests;
|
||||
|
||||
/// <summary>
|
||||
@@ -26,7 +28,8 @@ public sealed class AirGapControllerContractTests
|
||||
{
|
||||
#region AIRGAP-5100-010: Contract Tests
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public void Contract_ExportEndpoint_ExpectedRequestStructure()
|
||||
{
|
||||
// Arrange - Define expected request structure
|
||||
@@ -56,7 +59,8 @@ public sealed class AirGapControllerContractTests
|
||||
feeds.GetArrayLength().Should().BeGreaterThan(0);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public void Contract_ExportEndpoint_ExpectedResponseStructure()
|
||||
{
|
||||
// Arrange - Define expected response structure
|
||||
@@ -87,7 +91,8 @@ public sealed class AirGapControllerContractTests
|
||||
parsed.RootElement.TryGetProperty("manifest", out _).Should().BeTrue();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public void Contract_ImportEndpoint_ExpectedRequestStructure()
|
||||
{
|
||||
// Arrange - Import request (typically multipart form or bundle URL)
|
||||
@@ -107,7 +112,8 @@ public sealed class AirGapControllerContractTests
|
||||
parsed.RootElement.TryGetProperty("bundleDigest", out _).Should().BeTrue();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public void Contract_ImportEndpoint_ExpectedResponseStructure()
|
||||
{
|
||||
// Arrange
|
||||
@@ -131,7 +137,8 @@ public sealed class AirGapControllerContractTests
|
||||
parsed.RootElement.TryGetProperty("feedsImported", out _).Should().BeTrue();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public void Contract_ListBundlesEndpoint_ExpectedResponseStructure()
|
||||
{
|
||||
// Arrange
|
||||
@@ -164,7 +171,8 @@ public sealed class AirGapControllerContractTests
|
||||
parsed.RootElement.TryGetProperty("total", out _).Should().BeTrue();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public void Contract_StateEndpoint_ExpectedResponseStructure()
|
||||
{
|
||||
// Arrange - AirGap state response
|
||||
@@ -197,7 +205,8 @@ public sealed class AirGapControllerContractTests
|
||||
|
||||
#region AIRGAP-5100-011: Auth Tests
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public void Auth_RequiredScopes_ForExport()
|
||||
{
|
||||
// Arrange - Expected scopes for export operation
|
||||
@@ -207,7 +216,8 @@ public sealed class AirGapControllerContractTests
|
||||
requiredScopes.Should().Contain("airgap:export");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public void Auth_RequiredScopes_ForImport()
|
||||
{
|
||||
// Arrange - Expected scopes for import operation
|
||||
@@ -217,7 +227,8 @@ public sealed class AirGapControllerContractTests
|
||||
requiredScopes.Should().Contain("airgap:import");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public void Auth_RequiredScopes_ForList()
|
||||
{
|
||||
// Arrange - Expected scopes for list operation
|
||||
@@ -227,7 +238,8 @@ public sealed class AirGapControllerContractTests
|
||||
requiredScopes.Should().Contain("airgap:read");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public void Auth_DenyByDefault_NoTokenReturnsUnauthorized()
|
||||
{
|
||||
// Arrange - Request without token
|
||||
@@ -237,7 +249,8 @@ public sealed class AirGapControllerContractTests
|
||||
expectedStatusCode.Should().Be(HttpStatusCode.Unauthorized);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public void Auth_TenantIsolation_CannotAccessOtherTenantBundles()
|
||||
{
|
||||
// Arrange - Claims for tenant A
|
||||
@@ -256,7 +269,8 @@ public sealed class AirGapControllerContractTests
|
||||
// Requests for tenant-B bundles should be rejected
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public void Auth_TokenExpiry_ExpiredTokenReturnsForbidden()
|
||||
{
|
||||
// Arrange - Expired token scenario
|
||||
@@ -272,7 +286,8 @@ public sealed class AirGapControllerContractTests
|
||||
|
||||
#region AIRGAP-5100-012: OTel Trace Assertions
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public void OTel_ExportOperation_IncludesBundleIdTag()
|
||||
{
|
||||
// Arrange
|
||||
@@ -289,7 +304,8 @@ public sealed class AirGapControllerContractTests
|
||||
expectedTags.Should().Contain("operation");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public void OTel_ImportOperation_IncludesOperationTag()
|
||||
{
|
||||
// Arrange
|
||||
@@ -305,7 +321,8 @@ public sealed class AirGapControllerContractTests
|
||||
expectedTags["operation"].Should().Be("airgap.import");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public void OTel_Metrics_TracksExportCount()
|
||||
{
|
||||
// Arrange
|
||||
@@ -317,7 +334,8 @@ public sealed class AirGapControllerContractTests
|
||||
metricName.Should().NotBeNullOrEmpty();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public void OTel_Metrics_TracksImportCount()
|
||||
{
|
||||
// Arrange
|
||||
@@ -329,7 +347,8 @@ public sealed class AirGapControllerContractTests
|
||||
expectedDimensions.Should().Contain("status");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public void OTel_ActivitySource_HasCorrectName()
|
||||
{
|
||||
// Arrange
|
||||
@@ -339,7 +358,8 @@ public sealed class AirGapControllerContractTests
|
||||
expectedSourceName.Should().StartWith("StellaOps.");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public void OTel_Spans_PropagateTraceContext()
|
||||
{
|
||||
// Arrange - Create a trace context
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\\..\\StellaOps.AirGap.Importer\\StellaOps.AirGap.Importer.csproj" />
|
||||
<ProjectReference Include="../../../__Libraries/StellaOps.TestKit/StellaOps.TestKit.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
Reference in New Issue
Block a user