Some checks failed
AOC Guard CI / aoc-guard (push) Has been cancelled
AOC Guard CI / aoc-verify (push) Has been cancelled
Docs CI / lint-and-preview (push) Has been cancelled
Export Center CI / export-ci (push) Has been cancelled
Findings Ledger CI / build-test (push) Has been cancelled
Findings Ledger CI / migration-validation (push) Has been cancelled
Findings Ledger CI / generate-manifest (push) Has been cancelled
Lighthouse CI / Lighthouse Audit (push) Has been cancelled
Lighthouse CI / Axe Accessibility Audit (push) Has been cancelled
Policy Lint & Smoke / policy-lint (push) Has been cancelled
Reachability Corpus Validation / validate-corpus (push) Has been cancelled
Reachability Corpus Validation / validate-ground-truths (push) Has been cancelled
Scanner Analyzers / Discover Analyzers (push) Has been cancelled
Scanner Analyzers / Validate Test Fixtures (push) Has been cancelled
Signals CI & Image / signals-ci (push) Has been cancelled
Signals Reachability Scoring & Events / reachability-smoke (push) Has been cancelled
Reachability Corpus Validation / determinism-check (push) Has been cancelled
Scanner Analyzers / Build Analyzers (push) Has been cancelled
Scanner Analyzers / Test Language Analyzers (push) Has been cancelled
Scanner Analyzers / Verify Deterministic Output (push) Has been cancelled
Signals Reachability Scoring & Events / sign-and-upload (push) Has been cancelled
- Introduced `all-edge-reasons.json` to test edge resolution reasons in .NET. - Added `all-visibility-levels.json` to validate method visibility levels in .NET. - Created `dotnet-aspnetcore-minimal.json` for a minimal ASP.NET Core application. - Included `go-gin-api.json` for a Go Gin API application structure. - Added `java-spring-boot.json` for the Spring PetClinic application in Java. - Introduced `legacy-no-schema.json` for legacy application structure without schema. - Created `node-express-api.json` for an Express.js API application structure.
66 lines
2.0 KiB
C#
66 lines
2.0 KiB
C#
using FluentAssertions;
|
|
using StellaOps.AirGap.Importer.Reconciliation;
|
|
|
|
namespace StellaOps.AirGap.Importer.Tests.Reconciliation;
|
|
|
|
public sealed class ArtifactIndexTests
|
|
{
|
|
[Fact]
|
|
public void NormalizeDigest_BareHex_AddsPrefixAndLowercases()
|
|
{
|
|
var hex = new string('A', 64);
|
|
ArtifactIndex.NormalizeDigest(hex).Should().Be("sha256:" + new string('a', 64));
|
|
}
|
|
|
|
[Fact]
|
|
public void NormalizeDigest_WithSha256Prefix_IsCanonical()
|
|
{
|
|
var hex = new string('B', 64);
|
|
ArtifactIndex.NormalizeDigest("sha256:" + hex).Should().Be("sha256:" + new string('b', 64));
|
|
}
|
|
|
|
[Fact]
|
|
public void NormalizeDigest_WithOtherAlgorithm_Throws()
|
|
{
|
|
var ex = Assert.Throws<FormatException>(() => ArtifactIndex.NormalizeDigest("sha512:" + new string('a', 64)));
|
|
ex.Message.Should().Contain("Only sha256");
|
|
}
|
|
|
|
[Fact]
|
|
public void AddOrUpdate_MergesEntries_DeduplicatesAndSorts()
|
|
{
|
|
var digest = new string('c', 64);
|
|
|
|
var entryA = ArtifactEntry.Empty(digest) with
|
|
{
|
|
Sboms = new[]
|
|
{
|
|
new SbomReference("b", "b.json", SbomFormat.CycloneDx, null),
|
|
new SbomReference("a", "a.json", SbomFormat.Spdx, null),
|
|
}
|
|
};
|
|
|
|
var entryB = ArtifactEntry.Empty("sha256:" + digest.ToUpperInvariant()) with
|
|
{
|
|
Sboms = new[]
|
|
{
|
|
new SbomReference("a", "a2.json", SbomFormat.CycloneDx, null),
|
|
new SbomReference("c", "c.json", SbomFormat.Spdx, null),
|
|
}
|
|
};
|
|
|
|
var index = new ArtifactIndex();
|
|
index.AddOrUpdate(entryA);
|
|
index.AddOrUpdate(entryB);
|
|
|
|
var stored = index.Get("sha256:" + digest);
|
|
stored.Should().NotBeNull();
|
|
stored!.Digest.Should().Be("sha256:" + digest);
|
|
|
|
stored.Sboms.Select(s => (s.ContentHash, s.FilePath)).Should().Equal(
|
|
("a", "a.json"),
|
|
("b", "b.json"),
|
|
("c", "c.json"));
|
|
}
|
|
}
|