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

@@ -12,7 +12,8 @@ namespace StellaOps.AirGap.Policy.Tests;
public sealed class EgressPolicyTests
{
[Fact]
[Trait("Category", TestCategories.Unit)]
[Fact]
public void Evaluate_UnsealedEnvironment_AllowsRequest()
{
var options = new EgressPolicyOptions
@@ -29,7 +30,8 @@ public sealed class EgressPolicyTests
Assert.Null(decision.Reason);
}
[Fact]
[Trait("Category", TestCategories.Unit)]
[Fact]
public void EnsureAllowed_SealedEnvironmentWithMatchingRule_Allows()
{
var options = new EgressPolicyOptions
@@ -44,7 +46,8 @@ public sealed class EgressPolicyTests
policy.EnsureAllowed(request);
}
[Fact]
[Trait("Category", TestCategories.Unit)]
[Fact]
public void EnsureAllowed_SealedEnvironmentWithoutRule_ThrowsWithGuidance()
{
var options = new EgressPolicyOptions
@@ -67,7 +70,8 @@ public sealed class EgressPolicyTests
Assert.Equal(options.SupportContact, exception.SupportContact);
}
[Fact]
[Trait("Category", TestCategories.Unit)]
[Fact]
public void EnsureAllowed_SealedEnvironment_AllowsLoopbackWhenConfigured()
{
var options = new EgressPolicyOptions
@@ -82,7 +86,8 @@ public sealed class EgressPolicyTests
policy.EnsureAllowed(request);
}
[Fact]
[Trait("Category", TestCategories.Unit)]
[Fact]
public void EnsureAllowed_SealedEnvironment_AllowsPrivateNetworkWhenConfigured()
{
var options = new EgressPolicyOptions
@@ -97,7 +102,8 @@ public sealed class EgressPolicyTests
policy.EnsureAllowed(request);
}
[Fact]
[Trait("Category", TestCategories.Unit)]
[Fact]
public void EnsureAllowed_SealedEnvironment_BlocksPrivateNetworkWhenNotConfigured()
{
var options = new EgressPolicyOptions
@@ -113,7 +119,8 @@ public sealed class EgressPolicyTests
Assert.Contains("10.10.0.5", exception.Message, StringComparison.OrdinalIgnoreCase);
}
[Theory]
[Trait("Category", TestCategories.Unit)]
[Theory]
[InlineData("https://api.example.com", true)]
[InlineData("https://sub.api.example.com", true)]
[InlineData("https://example.com", false)]
@@ -132,7 +139,8 @@ public sealed class EgressPolicyTests
Assert.Equal(expectedAllowed, decision.IsAllowed);
}
[Fact]
[Trait("Category", TestCategories.Unit)]
[Fact]
public void ServiceCollection_AddAirGapEgressPolicy_RegistersService()
{
var services = new ServiceCollection();
@@ -149,7 +157,8 @@ public sealed class EgressPolicyTests
policy.EnsureAllowed(new EgressRequest("PolicyEngine", new Uri("https://mirror.internal"), "mirror-sync"));
}
[Fact]
[Trait("Category", TestCategories.Unit)]
[Fact]
public void ServiceCollection_AddAirGapEgressPolicy_BindsFromConfiguration()
{
var configuration = new ConfigurationBuilder()
@@ -182,7 +191,8 @@ public sealed class EgressPolicyTests
Assert.Contains("mirror.internal", blocked.Remediation, StringComparison.OrdinalIgnoreCase);
}
[Fact]
[Trait("Category", TestCategories.Unit)]
[Fact]
public void EgressHttpClientFactory_Create_EnforcesPolicyBeforeReturningClient()
{
var recordingPolicy = new RecordingPolicy();
@@ -190,6 +200,7 @@ public sealed class EgressPolicyTests
using var client = EgressHttpClientFactory.Create(recordingPolicy, request);
using StellaOps.TestKit;
Assert.True(recordingPolicy.EnsureAllowedCalled);
Assert.NotNull(client);
}