35 lines
1.0 KiB
C#
35 lines
1.0 KiB
C#
using System;
|
|
using System.Text;
|
|
using FluentAssertions;
|
|
using StellaOps.Replay.Core;
|
|
using Xunit;
|
|
|
|
namespace StellaOps.Replay.Core.Tests;
|
|
|
|
public sealed class DsseEnvelopeTests
|
|
{
|
|
[Fact]
|
|
public void BuildUnsigned_ProducesCanonicalPayload()
|
|
{
|
|
var manifest = new ReplayManifest
|
|
{
|
|
Scan = new ReplayScanMetadata
|
|
{
|
|
Id = "scan-123",
|
|
Time = DateTimeOffset.UnixEpoch
|
|
}
|
|
};
|
|
|
|
var envelope = DssePayloadBuilder.BuildUnsigned(manifest);
|
|
|
|
envelope.PayloadType.Should().Be(DssePayloadBuilder.ReplayPayloadType);
|
|
envelope.Signatures.Should().BeEmpty();
|
|
|
|
var payload = Convert.FromBase64String(envelope.Payload);
|
|
var json = Encoding.UTF8.GetString(payload);
|
|
|
|
json.Should().Be("{\"reachability\":{\"graphs\":[],\"runtimeTraces\":[]},\"scan\":{\"id\":\"scan-123\",\"time\":\"1970-01-01T00:00:00+00:00\"},\"schemaVersion\":\"1.0\"}");
|
|
envelope.DigestSha256.Should().Be(DeterministicHash.Sha256Hex(payload));
|
|
}
|
|
}
|