Refactor code structure and optimize performance across multiple modules
This commit is contained in:
@@ -6,6 +6,7 @@ using StellaOps.PacksRegistry.Core.Models;
|
||||
using StellaOps.PacksRegistry.Storage.Postgres.Repositories;
|
||||
using Xunit;
|
||||
|
||||
using StellaOps.TestKit;
|
||||
namespace StellaOps.PacksRegistry.Storage.Postgres.Tests;
|
||||
|
||||
[Collection(PacksRegistryPostgresCollection.Name)]
|
||||
@@ -32,7 +33,8 @@ public sealed class PostgresPackRepositoryTests : IAsyncLifetime
|
||||
|
||||
public Task DisposeAsync() => Task.CompletedTask;
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public async Task UpsertAndGet_RoundTripsPackRecord()
|
||||
{
|
||||
// Arrange
|
||||
@@ -64,7 +66,8 @@ public sealed class PostgresPackRepositoryTests : IAsyncLifetime
|
||||
fetched.Metadata.Should().ContainKey("author");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public async Task GetContentAsync_ReturnsPackContent()
|
||||
{
|
||||
// Arrange
|
||||
@@ -82,7 +85,8 @@ public sealed class PostgresPackRepositoryTests : IAsyncLifetime
|
||||
Encoding.UTF8.GetString(content!).Should().Be("this is the pack content");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public async Task GetProvenanceAsync_ReturnsProvenanceData()
|
||||
{
|
||||
// Arrange
|
||||
@@ -101,7 +105,8 @@ public sealed class PostgresPackRepositoryTests : IAsyncLifetime
|
||||
Encoding.UTF8.GetString(provenance!).Should().Be("provenance statement");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public async Task ListAsync_ReturnsPacksForTenant()
|
||||
{
|
||||
// Arrange
|
||||
@@ -119,7 +124,8 @@ public sealed class PostgresPackRepositoryTests : IAsyncLifetime
|
||||
packs.Should().HaveCount(2);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public async Task UpsertAsync_UpdatesExistingPack()
|
||||
{
|
||||
// Arrange
|
||||
|
||||
@@ -7,7 +7,8 @@ namespace StellaOps.PacksRegistry.Tests;
|
||||
|
||||
public sealed class ExportServiceTests
|
||||
{
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public async Task Offline_seed_includes_metadata_and_content_when_requested()
|
||||
{
|
||||
var ct = TestContext.Current.CancellationToken;
|
||||
@@ -31,6 +32,7 @@ public sealed class ExportServiceTests
|
||||
var archiveStream = await exportService.ExportOfflineSeedAsync(record.TenantId, includeContent: true, includeProvenance: true, cancellationToken: ct);
|
||||
using var archive = new ZipArchive(archiveStream, ZipArchiveMode.Read);
|
||||
|
||||
using StellaOps.TestKit;
|
||||
Assert.NotNull(archive.GetEntry("packs.ndjson"));
|
||||
Assert.NotNull(archive.GetEntry("parity.ndjson"));
|
||||
Assert.NotNull(archive.GetEntry("lifecycle.ndjson"));
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
using StellaOps.PacksRegistry.Core.Models;
|
||||
using StellaOps.PacksRegistry.Infrastructure.FileSystem;
|
||||
|
||||
using StellaOps.TestKit;
|
||||
namespace StellaOps.PacksRegistry.Tests;
|
||||
|
||||
public sealed class FilePackRepositoryTests
|
||||
{
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public async Task Upsert_and_List_round_trip()
|
||||
{
|
||||
var tempPath = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString("N"));
|
||||
|
||||
@@ -2,13 +2,15 @@ using StellaOps.PacksRegistry.Core.Services;
|
||||
using StellaOps.PacksRegistry.Infrastructure.InMemory;
|
||||
using StellaOps.PacksRegistry.Infrastructure.Verification;
|
||||
|
||||
using StellaOps.TestKit;
|
||||
namespace StellaOps.PacksRegistry.Tests;
|
||||
|
||||
public sealed class PackServiceTests
|
||||
{
|
||||
private static byte[] SampleContent => System.Text.Encoding.UTF8.GetBytes("sample-pack-content");
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public async Task Upload_persists_pack_with_digest()
|
||||
{
|
||||
var ct = TestContext.Current.CancellationToken;
|
||||
@@ -35,7 +37,8 @@ public sealed class PackServiceTests
|
||||
Assert.Equal(record.PackId, listed[0].PackId);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public async Task Upload_rejects_when_digest_mismatch()
|
||||
{
|
||||
var ct = TestContext.Current.CancellationToken;
|
||||
@@ -56,7 +59,8 @@ public sealed class PackServiceTests
|
||||
cancellationToken: ct));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public async Task Rotate_signature_updates_record_and_audits()
|
||||
{
|
||||
var ct = TestContext.Current.CancellationToken;
|
||||
|
||||
@@ -42,7 +42,8 @@ public sealed class PacksApiTests : IClassFixture<WebApplicationFactory<Program>
|
||||
});
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public async Task Upload_and_download_round_trip()
|
||||
{
|
||||
var ct = TestContext.Current.CancellationToken;
|
||||
@@ -121,6 +122,7 @@ public sealed class PacksApiTests : IClassFixture<WebApplicationFactory<Program>
|
||||
Assert.Equal(HttpStatusCode.OK, offlineSeed.StatusCode);
|
||||
var bytesZip = await offlineSeed.Content.ReadAsByteArrayAsync(ct);
|
||||
using var archive = new ZipArchive(new MemoryStream(bytesZip));
|
||||
using StellaOps.TestKit;
|
||||
Assert.NotNull(archive.GetEntry("packs.ndjson"));
|
||||
Assert.NotNull(archive.GetEntry($"content/{created.PackId}.bin"));
|
||||
}
|
||||
|
||||
@@ -6,7 +6,8 @@ namespace StellaOps.PacksRegistry.Tests;
|
||||
|
||||
public sealed class RsaSignatureVerifierTests
|
||||
{
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public async Task Verify_succeeds_when_signature_matches_digest()
|
||||
{
|
||||
var ct = TestContext.Current.CancellationToken;
|
||||
@@ -22,11 +23,13 @@ public sealed class RsaSignatureVerifierTests
|
||||
Assert.True(ok);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public async Task Verify_fails_on_invalid_signature()
|
||||
{
|
||||
var ct = TestContext.Current.CancellationToken;
|
||||
using var rsa = RSA.Create(2048);
|
||||
using StellaOps.TestKit;
|
||||
var publicPem = ExportPublicPem(rsa);
|
||||
const string digest = "sha256:deadbeef";
|
||||
var sig = Convert.ToBase64String(Encoding.UTF8.GetBytes("bogus"));
|
||||
|
||||
Reference in New Issue
Block a user