Refactor code structure and optimize performance across multiple modules
This commit is contained in:
@@ -5,6 +5,7 @@ using StellaOps.SbomService.Models;
|
||||
using StellaOps.SbomService.Storage.Postgres.Repositories;
|
||||
using Xunit;
|
||||
|
||||
using StellaOps.TestKit;
|
||||
namespace StellaOps.SbomService.Storage.Postgres.Tests;
|
||||
|
||||
[Collection(SbomServicePostgresCollection.Name)]
|
||||
@@ -31,7 +32,8 @@ public sealed class PostgresEntrypointRepositoryTests : IAsyncLifetime
|
||||
|
||||
public Task DisposeAsync() => Task.CompletedTask;
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public async Task UpsertAndList_RoundTripsEntrypoint()
|
||||
{
|
||||
// Arrange
|
||||
@@ -54,7 +56,8 @@ public sealed class PostgresEntrypointRepositoryTests : IAsyncLifetime
|
||||
fetched[0].RuntimeFlag.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public async Task UpsertAsync_UpdatesExistingEntrypoint()
|
||||
{
|
||||
// Arrange
|
||||
@@ -73,7 +76,8 @@ public sealed class PostgresEntrypointRepositoryTests : IAsyncLifetime
|
||||
fetched[0].RuntimeFlag.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public async Task ListAsync_ReturnsOrderedByArtifactServicePath()
|
||||
{
|
||||
// Arrange
|
||||
@@ -93,7 +97,8 @@ public sealed class PostgresEntrypointRepositoryTests : IAsyncLifetime
|
||||
fetched[2].Artifact.Should().Be("z-api");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public async Task ListAsync_ReturnsEmptyForUnknownTenant()
|
||||
{
|
||||
// Act
|
||||
|
||||
@@ -5,6 +5,7 @@ using StellaOps.SbomService.Services;
|
||||
using StellaOps.SbomService.Storage.Postgres.Repositories;
|
||||
using Xunit;
|
||||
|
||||
using StellaOps.TestKit;
|
||||
namespace StellaOps.SbomService.Storage.Postgres.Tests;
|
||||
|
||||
[Collection(SbomServicePostgresCollection.Name)]
|
||||
@@ -31,7 +32,8 @@ public sealed class PostgresOrchestratorControlRepositoryTests : IAsyncLifetime
|
||||
|
||||
public Task DisposeAsync() => Task.CompletedTask;
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public async Task GetAsync_ReturnsDefaultStateForNewTenant()
|
||||
{
|
||||
// Act
|
||||
@@ -45,7 +47,8 @@ public sealed class PostgresOrchestratorControlRepositoryTests : IAsyncLifetime
|
||||
state.Backpressure.Should().Be("normal");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public async Task SetAsync_PersistsControlState()
|
||||
{
|
||||
// Arrange
|
||||
@@ -66,7 +69,8 @@ public sealed class PostgresOrchestratorControlRepositoryTests : IAsyncLifetime
|
||||
fetched.Backpressure.Should().Be("high");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public async Task SetAsync_UpdatesExistingState()
|
||||
{
|
||||
// Arrange
|
||||
@@ -84,7 +88,8 @@ public sealed class PostgresOrchestratorControlRepositoryTests : IAsyncLifetime
|
||||
fetched.Backpressure.Should().Be("critical");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public async Task ListAsync_ReturnsAllStates()
|
||||
{
|
||||
// Arrange
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\StellaOps.SbomService.Storage.Postgres\StellaOps.SbomService.Storage.Postgres.csproj" />
|
||||
<ProjectReference Include="..\..\__Tests\__Libraries\StellaOps.Infrastructure.Postgres.Testing\StellaOps.Infrastructure.Postgres.Testing.csproj" />
|
||||
<ProjectReference Include="../../__Libraries/StellaOps.TestKit/StellaOps.TestKit.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -4,6 +4,7 @@ using FluentAssertions;
|
||||
using Microsoft.AspNetCore.Mvc.Testing;
|
||||
using StellaOps.SbomService.Models;
|
||||
|
||||
using StellaOps.TestKit;
|
||||
namespace StellaOps.SbomService.Tests;
|
||||
|
||||
public class EntrypointEndpointsTests : IClassFixture<WebApplicationFactory<Program>>
|
||||
@@ -15,7 +16,8 @@ public class EntrypointEndpointsTests : IClassFixture<WebApplicationFactory<Prog
|
||||
_factory = factory;
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public async Task Get_entrypoints_requires_tenant()
|
||||
{
|
||||
var client = _factory.CreateClient();
|
||||
@@ -24,7 +26,8 @@ public class EntrypointEndpointsTests : IClassFixture<WebApplicationFactory<Prog
|
||||
response.StatusCode.Should().Be(HttpStatusCode.BadRequest);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public async Task Get_entrypoints_returns_seeded_list()
|
||||
{
|
||||
var client = _factory.CreateClient();
|
||||
@@ -39,7 +42,8 @@ public class EntrypointEndpointsTests : IClassFixture<WebApplicationFactory<Prog
|
||||
payload.Items.Select(e => e.Artifact).Should().Contain("ghcr.io/stellaops/sample-api");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public async Task Post_entrypoints_upserts_and_returns_ordered_list()
|
||||
{
|
||||
var client = _factory.CreateClient();
|
||||
|
||||
@@ -6,6 +6,7 @@ using StellaOps.SbomService.Models;
|
||||
using System.Text.Json;
|
||||
using Xunit;
|
||||
|
||||
using StellaOps.TestKit;
|
||||
namespace StellaOps.SbomService.Tests;
|
||||
|
||||
public class OrchestratorEndpointsTests : IClassFixture<WebApplicationFactory<Program>>
|
||||
@@ -17,7 +18,8 @@ public class OrchestratorEndpointsTests : IClassFixture<WebApplicationFactory<Pr
|
||||
_factory = factory;
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public async Task List_sources_requires_tenant()
|
||||
{
|
||||
var client = _factory.CreateClient();
|
||||
@@ -25,7 +27,8 @@ public class OrchestratorEndpointsTests : IClassFixture<WebApplicationFactory<Pr
|
||||
response.StatusCode.Should().Be(HttpStatusCode.BadRequest);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public async Task List_and_register_sources_are_deterministic()
|
||||
{
|
||||
var client = _factory.CreateClient();
|
||||
|
||||
@@ -10,6 +10,7 @@ using Microsoft.Extensions.DependencyInjection.Extensions;
|
||||
using StellaOps.SbomService.Repositories;
|
||||
using Xunit;
|
||||
|
||||
using StellaOps.TestKit;
|
||||
namespace StellaOps.SbomService.Tests;
|
||||
|
||||
public class ProjectionEndpointTests : IClassFixture<WebApplicationFactory<Program>>
|
||||
@@ -46,7 +47,8 @@ public class ProjectionEndpointTests : IClassFixture<WebApplicationFactory<Progr
|
||||
});
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public async Task Projection_requires_tenant()
|
||||
{
|
||||
var client = _factory.CreateClient();
|
||||
@@ -60,7 +62,8 @@ public class ProjectionEndpointTests : IClassFixture<WebApplicationFactory<Progr
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public async Task Projection_returns_payload_and_hash()
|
||||
{
|
||||
var client = _factory.CreateClient();
|
||||
|
||||
@@ -5,6 +5,7 @@ using Microsoft.AspNetCore.Mvc.Testing;
|
||||
using StellaOps.SbomService.Models;
|
||||
using Xunit;
|
||||
|
||||
using StellaOps.TestKit;
|
||||
namespace StellaOps.SbomService.Tests;
|
||||
|
||||
public class ResolverFeedExportTests : IClassFixture<WebApplicationFactory<Program>>
|
||||
@@ -16,7 +17,8 @@ public class ResolverFeedExportTests : IClassFixture<WebApplicationFactory<Progr
|
||||
_factory = factory;
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public async Task Export_returns_ndjson_in_deterministic_order()
|
||||
{
|
||||
var client = _factory.CreateClient();
|
||||
|
||||
@@ -5,6 +5,7 @@ using Microsoft.AspNetCore.Mvc.Testing;
|
||||
using StellaOps.SbomService.Models;
|
||||
using Xunit;
|
||||
|
||||
using StellaOps.TestKit;
|
||||
namespace StellaOps.SbomService.Tests;
|
||||
|
||||
public class SbomAssetEventsTests : IClassFixture<WebApplicationFactory<Program>>
|
||||
@@ -16,7 +17,8 @@ public class SbomAssetEventsTests : IClassFixture<WebApplicationFactory<Program>
|
||||
_factory = factory;
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public async Task Projection_emits_asset_event_once()
|
||||
{
|
||||
var client = _factory.CreateClient();
|
||||
|
||||
@@ -5,6 +5,7 @@ using Microsoft.AspNetCore.Mvc.Testing;
|
||||
using StellaOps.SbomService.Models;
|
||||
using Xunit;
|
||||
|
||||
using StellaOps.TestKit;
|
||||
namespace StellaOps.SbomService.Tests;
|
||||
|
||||
public class SbomEndpointsTests : IClassFixture<WebApplicationFactory<Program>>
|
||||
@@ -16,7 +17,8 @@ public class SbomEndpointsTests : IClassFixture<WebApplicationFactory<Program>>
|
||||
_factory = factory.WithWebHostBuilder(_ => { });
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public async Task Paths_requires_purl()
|
||||
{
|
||||
var client = _factory.CreateClient();
|
||||
@@ -27,7 +29,8 @@ public class SbomEndpointsTests : IClassFixture<WebApplicationFactory<Program>>
|
||||
response.StatusCode.Should().Be(HttpStatusCode.BadRequest, body);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public async Task Paths_returns_seeded_paths_with_cursor()
|
||||
{
|
||||
var client = _factory.CreateClient();
|
||||
@@ -42,7 +45,8 @@ public class SbomEndpointsTests : IClassFixture<WebApplicationFactory<Program>>
|
||||
payload.NextCursor.Should().Be("1");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public async Task Versions_returns_descending_timeline()
|
||||
{
|
||||
var client = _factory.CreateClient();
|
||||
@@ -56,7 +60,8 @@ public class SbomEndpointsTests : IClassFixture<WebApplicationFactory<Program>>
|
||||
payload.Versions.Should().BeInDescendingOrder(v => v.CreatedAt);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public async Task Console_sboms_supports_filters_and_cursor()
|
||||
{
|
||||
var client = _factory.CreateClient();
|
||||
@@ -71,7 +76,8 @@ public class SbomEndpointsTests : IClassFixture<WebApplicationFactory<Program>>
|
||||
payload.NextCursor.Should().Be("1");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public async Task Console_sboms_filters_by_license_and_asset_tag()
|
||||
{
|
||||
var client = _factory.CreateClient();
|
||||
@@ -85,7 +91,8 @@ public class SbomEndpointsTests : IClassFixture<WebApplicationFactory<Program>>
|
||||
payload.NextCursor.Should().BeNull();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public async Task Console_sboms_paginates_with_cursor_offset()
|
||||
{
|
||||
var client = _factory.CreateClient();
|
||||
@@ -104,7 +111,8 @@ public class SbomEndpointsTests : IClassFixture<WebApplicationFactory<Program>>
|
||||
secondPage.NextCursor.Should().BeNull();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public async Task Components_lookup_requires_purl_and_paginates()
|
||||
{
|
||||
var client = _factory.CreateClient();
|
||||
@@ -130,7 +138,8 @@ public class SbomEndpointsTests : IClassFixture<WebApplicationFactory<Program>>
|
||||
secondPage.NextCursor.Should().BeNull();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public async Task Context_requires_artifact_id()
|
||||
{
|
||||
var client = _factory.CreateClient();
|
||||
@@ -140,7 +149,8 @@ public class SbomEndpointsTests : IClassFixture<WebApplicationFactory<Program>>
|
||||
response.StatusCode.Should().Be(HttpStatusCode.BadRequest);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public async Task Context_returns_versions_and_paths_with_hash()
|
||||
{
|
||||
var client = _factory.CreateClient();
|
||||
@@ -157,7 +167,8 @@ public class SbomEndpointsTests : IClassFixture<WebApplicationFactory<Program>>
|
||||
payload.Hash.Should().StartWith("sha256:", StringComparison.Ordinal);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public async Task Context_includes_environment_flags_and_blast_radius_when_requested()
|
||||
{
|
||||
var client = _factory.CreateClient();
|
||||
@@ -174,7 +185,8 @@ public class SbomEndpointsTests : IClassFixture<WebApplicationFactory<Program>>
|
||||
payload.BlastRadius.Metadata.Should().ContainKey("blast_radius_tags");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public async Task Context_honors_zero_timeline_limit_and_dependency_results()
|
||||
{
|
||||
var client = _factory.CreateClient();
|
||||
@@ -190,7 +202,8 @@ public class SbomEndpointsTests : IClassFixture<WebApplicationFactory<Program>>
|
||||
payload.BlastRadius.Should().BeNull();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public async Task Context_returns_not_found_when_no_data()
|
||||
{
|
||||
var client = _factory.CreateClient();
|
||||
|
||||
@@ -6,6 +6,7 @@ using Microsoft.AspNetCore.Mvc.Testing;
|
||||
using StellaOps.SbomService.Models;
|
||||
using Xunit;
|
||||
|
||||
using StellaOps.TestKit;
|
||||
namespace StellaOps.SbomService.Tests;
|
||||
|
||||
public class SbomEventEndpointsTests : IClassFixture<WebApplicationFactory<Program>>
|
||||
@@ -17,7 +18,8 @@ public class SbomEventEndpointsTests : IClassFixture<WebApplicationFactory<Progr
|
||||
_factory = factory.WithWebHostBuilder(_ => { });
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public async Task Backfill_publishes_version_created_events_once()
|
||||
{
|
||||
var client = _factory.CreateClient();
|
||||
|
||||
@@ -5,6 +5,7 @@ using Microsoft.AspNetCore.Mvc.Testing;
|
||||
using StellaOps.SbomService.Models;
|
||||
using Xunit;
|
||||
|
||||
using StellaOps.TestKit;
|
||||
namespace StellaOps.SbomService.Tests;
|
||||
|
||||
public class SbomInventoryEventsTests : IClassFixture<WebApplicationFactory<Program>>
|
||||
@@ -16,7 +17,8 @@ public class SbomInventoryEventsTests : IClassFixture<WebApplicationFactory<Prog
|
||||
_factory = factory;
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public async Task Inventory_events_emitted_on_projection()
|
||||
{
|
||||
var client = _factory.CreateClient();
|
||||
@@ -31,7 +33,8 @@ public class SbomInventoryEventsTests : IClassFixture<WebApplicationFactory<Prog
|
||||
items.Should().ContainSingle(i => i.Purl == "pkg:npm/lodash@4.17.21" && i.Scope == "runtime");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public async Task Inventory_backfill_resets_and_replays()
|
||||
{
|
||||
var client = _factory.CreateClient();
|
||||
@@ -47,7 +50,8 @@ public class SbomInventoryEventsTests : IClassFixture<WebApplicationFactory<Prog
|
||||
post!.Count.Should().BeGreaterOrEqualTo(pre!.Count);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public async Task Resolver_feed_backfill_populates_candidates()
|
||||
{
|
||||
var client = _factory.CreateClient();
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System.Net;
|
||||
using System.Net;
|
||||
using System.Net.Http.Json;
|
||||
using System.Text.Json;
|
||||
using FluentAssertions;
|
||||
@@ -6,6 +6,8 @@ using Microsoft.AspNetCore.Mvc.Testing;
|
||||
using StellaOps.SbomService.Models;
|
||||
using Xunit;
|
||||
|
||||
|
||||
using StellaOps.TestKit;
|
||||
namespace StellaOps.SbomService.Tests;
|
||||
|
||||
public sealed class SbomLedgerEndpointsTests : IClassFixture<WebApplicationFactory<Program>>
|
||||
@@ -17,7 +19,8 @@ public sealed class SbomLedgerEndpointsTests : IClassFixture<WebApplicationFacto
|
||||
_factory = factory.WithWebHostBuilder(_ => { });
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public async Task Upload_accepts_cyclonedx_and_returns_analysis_job()
|
||||
{
|
||||
var client = _factory.CreateClient();
|
||||
@@ -34,7 +37,8 @@ public sealed class SbomLedgerEndpointsTests : IClassFixture<WebApplicationFacto
|
||||
payload.AnalysisJobId.Should().NotBeNullOrWhiteSpace();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public async Task Upload_accepts_spdx_and_records_history()
|
||||
{
|
||||
var client = _factory.CreateClient();
|
||||
@@ -65,7 +69,8 @@ public sealed class SbomLedgerEndpointsTests : IClassFixture<WebApplicationFacto
|
||||
diffPayload!.Summary.VersionChangedCount.Should().Be(1);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public async Task Lineage_includes_build_edges_for_shared_build_id()
|
||||
{
|
||||
var client = _factory.CreateClient();
|
||||
|
||||
@@ -12,5 +12,6 @@
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="../StellaOps.SbomService/StellaOps.SbomService.csproj" />
|
||||
<ProjectReference Include="../../__Libraries/StellaOps.TestKit/StellaOps.TestKit.csproj" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
||||
Reference in New Issue
Block a user