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 b4fc66feb6
3353 changed files with 88254 additions and 1590657 deletions

View File

@@ -12,13 +12,16 @@ using StellaOps.Scanner.WebService.Endpoints;
using Xunit;
using FluentAssertions;
using StellaOps.TestKit;
namespace StellaOps.Scanner.WebService.Tests;
public sealed class EvidenceEndpointsTests
{
private static readonly JsonSerializerOptions SerializerOptions = new(JsonSerializerDefaults.Web);
[Fact]
[Trait("Category", TestCategories.Unit)]
[Fact]
public async Task GetEvidence_ReturnsBadRequest_WhenScanIdInvalid()
{
using var secrets = new TestSurfaceSecretsScope();
@@ -34,7 +37,8 @@ public sealed class EvidenceEndpointsTests
response.StatusCode.Should().Be(HttpStatusCode.NotFound); // Route doesn't match
}
[Fact]
[Trait("Category", TestCategories.Unit)]
[Fact]
public async Task GetEvidence_ReturnsNotFound_WhenScanDoesNotExist()
{
using var secrets = new TestSurfaceSecretsScope();
@@ -50,7 +54,8 @@ public sealed class EvidenceEndpointsTests
response.StatusCode.Should().Be(HttpStatusCode.NotFound);
}
[Fact]
[Trait("Category", TestCategories.Unit)]
[Fact]
public async Task GetEvidence_ReturnsListEndpoint_WhenFindingIdEmpty()
{
// When no finding ID is provided, the route matches the list endpoint
@@ -71,7 +76,8 @@ public sealed class EvidenceEndpointsTests
response.StatusCode.Should().Be(HttpStatusCode.OK);
}
[Fact]
[Trait("Category", TestCategories.Unit)]
[Fact]
public async Task ListEvidence_ReturnsEmptyList_WhenNoFindings()
{
using var secrets = new TestSurfaceSecretsScope();
@@ -93,7 +99,8 @@ public sealed class EvidenceEndpointsTests
result.Items.Should().BeEmpty();
}
[Fact]
[Trait("Category", TestCategories.Unit)]
[Fact]
public async Task ListEvidence_ReturnsEmptyList_WhenScanDoesNotExist()
{
// The current implementation returns empty list for non-existent scans
@@ -134,7 +141,8 @@ public sealed class EvidenceEndpointsTests
/// </summary>
public sealed class EvidenceTtlTests
{
[Fact]
[Trait("Category", TestCategories.Unit)]
[Fact]
public void DefaultEvidenceTtlDays_DefaultsToSevenDays()
{
// Verify the default configuration
@@ -143,7 +151,8 @@ public sealed class EvidenceTtlTests
options.DefaultEvidenceTtlDays.Should().Be(7);
}
[Fact]
[Trait("Category", TestCategories.Unit)]
[Fact]
public void VexEvidenceTtlDays_DefaultsToThirtyDays()
{
var options = new StellaOps.Scanner.WebService.Services.EvidenceCompositionOptions();
@@ -151,7 +160,8 @@ public sealed class EvidenceTtlTests
options.VexEvidenceTtlDays.Should().Be(30);
}
[Fact]
[Trait("Category", TestCategories.Unit)]
[Fact]
public void StaleWarningThresholdDays_DefaultsToOne()
{
var options = new StellaOps.Scanner.WebService.Services.EvidenceCompositionOptions();
@@ -159,7 +169,8 @@ public sealed class EvidenceTtlTests
options.StaleWarningThresholdDays.Should().Be(1);
}
[Fact]
[Trait("Category", TestCategories.Unit)]
[Fact]
public void EvidenceCompositionOptions_CanBeConfigured()
{
var options = new StellaOps.Scanner.WebService.Services.EvidenceCompositionOptions