up
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
using FluentAssertions;
|
||||
using MongoDB.Bson.Serialization;
|
||||
using StellaOps.Replay.Core;
|
||||
using Xunit;
|
||||
|
||||
namespace StellaOps.Replay.Core.Tests;
|
||||
|
||||
public sealed class ReplayMongoModelsTests
|
||||
{
|
||||
[Fact]
|
||||
public void ReplayRunRecord_SerializesWithExpectedFields()
|
||||
{
|
||||
var record = new ReplayRunRecord
|
||||
{
|
||||
Id = "scan-1",
|
||||
ManifestHash = "sha256:abc",
|
||||
Status = "verified",
|
||||
Outputs = new ReplayRunOutputs { Sbom = "sha256:sbom", Findings = "sha256:findings", Vex = "sha256:vex" },
|
||||
Signatures = new() { new ReplaySignatureRecord { Profile = "FIPS", Verified = true } }
|
||||
};
|
||||
|
||||
var bson = record.ToBsonDocument();
|
||||
|
||||
bson.Should().ContainKey("_id");
|
||||
bson["manifestHash"].AsString.Should().Be("sha256:abc");
|
||||
bson["status"].AsString.Should().Be("verified");
|
||||
bson["outputs"].AsBsonDocument["sbom"].AsString.Should().Be("sha256:sbom");
|
||||
bson["signatures"].AsBsonArray.Should().HaveCount(1);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ReplayBundleRecord_UsesIdAsDigest()
|
||||
{
|
||||
var record = new ReplayBundleRecord { Id = "abc", Type = "input", Size = 10, Location = "cas://replay/ab/abc.tar.zst" };
|
||||
|
||||
var bson = record.ToBsonDocument();
|
||||
bson["_id"].AsString.Should().Be("abc");
|
||||
bson["type"].AsString.Should().Be("input");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ReplaySubjectRecord_StoresLayers()
|
||||
{
|
||||
var record = new ReplaySubjectRecord
|
||||
{
|
||||
OciDigest = "sha256:img",
|
||||
Layers = new()
|
||||
{
|
||||
new ReplayLayerRecord { LayerDigest = "l1", MerkleRoot = "m1", LeafCount = 2 },
|
||||
new ReplayLayerRecord { LayerDigest = "l2", MerkleRoot = "m2", LeafCount = 3 }
|
||||
}
|
||||
};
|
||||
|
||||
var doc = record.ToBsonDocument();
|
||||
doc["layers"].AsBsonArray.Should().HaveCount(2);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user