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

@@ -30,7 +30,8 @@ namespace StellaOps.Policy.Gateway.Tests;
public sealed class GatewayActivationTests
{
[Fact]
[Trait("Category", TestCategories.Unit)]
[Fact]
public async Task ActivateRevision_UsesServiceTokenFallback_And_RecordsMetrics()
{
await using var factory = new PolicyGatewayWebApplicationFactory();
@@ -114,7 +115,8 @@ public sealed class GatewayActivationTests
measurement.Source == "service");
}
[Fact]
[Trait("Category", TestCategories.Unit)]
[Fact]
public async Task ActivateRevision_CompletesDualControlWorkflow()
{
await using var factory = new PolicyGatewayWebApplicationFactory();
@@ -154,7 +156,8 @@ public sealed class GatewayActivationTests
Assert.Equal(2, recordingHandler.RequestCount);
}
[Fact]
[Trait("Category", TestCategories.Unit)]
[Fact]
public async Task ActivateRevision_RecordsMetrics_WhenUpstreamReturnsUnauthorized()
{
await using var factory = new PolicyGatewayWebApplicationFactory();
@@ -240,7 +243,8 @@ public sealed class GatewayActivationTests
measurement.Source == "service");
}
[Fact]
[Trait("Category", TestCategories.Unit)]
[Fact]
public async Task ActivateRevision_RecordsMetrics_WhenUpstreamReturnsBadGateway()
{
await using var factory = new PolicyGatewayWebApplicationFactory();
@@ -326,7 +330,8 @@ public sealed class GatewayActivationTests
measurement.Source == "service");
}
[Fact]
[Trait("Category", TestCategories.Unit)]
[Fact]
public async Task ActivateRevision_RetriesOnTooManyRequests()
{
await using var factory = new PolicyGatewayWebApplicationFactory();
@@ -353,6 +358,7 @@ public sealed class GatewayActivationTests
using var client = factory.CreateClient();
using StellaOps.TestKit;
try
{
var response = await client.PostAsJsonAsync(

View File

@@ -25,7 +25,8 @@ namespace StellaOps.Policy.Gateway.Tests;
public class PolicyEngineClientTests
{
[Fact]
[Trait("Category", TestCategories.Unit)]
[Fact]
public async Task ActivateRevision_UsesServiceTokenWhenForwardingContextMissing()
{
var options = CreateGatewayOptions();
@@ -61,11 +62,13 @@ public class PolicyEngineClientTests
Assert.Equal(1, tokenClient.RequestCount);
}
[Fact]
[Trait("Category", TestCategories.Unit)]
[Fact]
public void Metrics_RecordActivation_EmitsExpectedTags()
{
using var metrics = new PolicyGatewayMetrics();
using var listener = new MeterListener();
using StellaOps.TestKit;
var measurements = new List<(long Value, string Outcome, string Source)>();
var latencies = new List<(double Value, string Outcome, string Source)>();

View File

@@ -16,7 +16,8 @@ namespace StellaOps.Policy.Gateway.Tests;
public sealed class PolicyGatewayDpopProofGeneratorTests
{
[Fact]
[Trait("Category", TestCategories.Unit)]
[Fact]
public void CreateProof_Throws_WhenDpopDisabled()
{
var options = CreateGatewayOptions();
@@ -34,7 +35,8 @@ public sealed class PolicyGatewayDpopProofGeneratorTests
Assert.Equal("DPoP proof requested while DPoP is disabled.", exception.Message);
}
[Fact]
[Trait("Category", TestCategories.Unit)]
[Fact]
public void CreateProof_Throws_WhenKeyFileMissing()
{
var tempRoot = Directory.CreateTempSubdirectory();
@@ -61,7 +63,8 @@ public sealed class PolicyGatewayDpopProofGeneratorTests
}
}
[Fact]
[Trait("Category", TestCategories.Unit)]
[Fact]
public void CreateProof_UsesConfiguredAlgorithmAndEmbedsTokenHash()
{
var tempRoot = Directory.CreateTempSubdirectory();
@@ -120,6 +123,7 @@ public sealed class PolicyGatewayDpopProofGeneratorTests
private static string CreateEcKey(DirectoryInfo directory, ECCurve curve)
{
using var ecdsa = ECDsa.Create(curve);
using StellaOps.TestKit;
var privateKey = ecdsa.ExportPkcs8PrivateKey();
var pem = PemEncoding.Write("PRIVATE KEY", privateKey);
var path = Path.Combine(directory.FullName, "policy-gateway-dpop.pem");