Refactor code structure and optimize performance across multiple modules
This commit is contained in:
@@ -3,6 +3,7 @@ using StellaOps.Cryptography;
|
||||
using StellaOps.Orchestrator.Core.Domain;
|
||||
using StellaOps.Orchestrator.Core.Hashing;
|
||||
|
||||
using StellaOps.TestKit;
|
||||
namespace StellaOps.Orchestrator.Tests;
|
||||
|
||||
public class CanonicalJsonHasherTests
|
||||
@@ -15,7 +16,8 @@ public class CanonicalJsonHasherTests
|
||||
_hasher = new CanonicalJsonHasher(_cryptoHash);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public void ProducesStableHash_WhenObjectPropertyOrderDiffers()
|
||||
{
|
||||
var first = new { b = 1, a = 2 };
|
||||
@@ -27,7 +29,8 @@ public class CanonicalJsonHasherTests
|
||||
Assert.Equal(firstHash, secondHash);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public void CanonicalJson_SortsKeysAndPreservesArrays()
|
||||
{
|
||||
var value = new
|
||||
@@ -42,7 +45,8 @@ public class CanonicalJsonHasherTests
|
||||
Assert.Equal("{\"items\":[\"first\",\"second\"],\"meta\":{\"a\":2,\"z\":1}}", json);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public void AuditEntry_UsesCanonicalHash()
|
||||
{
|
||||
var entry = AuditEntry.Create(
|
||||
|
||||
@@ -4,6 +4,7 @@ using StellaOps.Cryptography;
|
||||
using StellaOps.Orchestrator.Core;
|
||||
using StellaOps.Orchestrator.Core.Hashing;
|
||||
|
||||
using StellaOps.TestKit;
|
||||
namespace StellaOps.Orchestrator.Tests;
|
||||
|
||||
public class EventEnvelopeTests
|
||||
@@ -17,14 +18,16 @@ public class EventEnvelopeTests
|
||||
_hasher = new CanonicalJsonHasher(_cryptoHash);
|
||||
_envelopeHasher = new EventEnvelopeHasher(_hasher);
|
||||
}
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public void ComputeIdempotencyKey_IsDeterministicAndLowercase()
|
||||
{
|
||||
var key = EventEnvelope.ComputeIdempotencyKey("Job.Completed", "job_abc", 3);
|
||||
Assert.Equal("orch-job.completed-job_abc-3", key);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public void Create_PopulatesDefaultsAndSerializes()
|
||||
{
|
||||
var job = new EventJob(
|
||||
@@ -64,7 +67,8 @@ public class EventEnvelopeTests
|
||||
Assert.Equal(envelope.Actor.Subject, roundtrip.Actor.Subject);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public void Hash_IsDeterministic()
|
||||
{
|
||||
var job = new EventJob(
|
||||
|
||||
@@ -3,6 +3,7 @@ using StellaOps.Cryptography;
|
||||
using StellaOps.Orchestrator.Core.Domain.Replay;
|
||||
using StellaOps.Orchestrator.Core.Hashing;
|
||||
|
||||
using StellaOps.TestKit;
|
||||
namespace StellaOps.Orchestrator.Tests;
|
||||
|
||||
public class ReplayInputsLockTests
|
||||
@@ -15,7 +16,8 @@ public class ReplayInputsLockTests
|
||||
_hasher = new CanonicalJsonHasher(_cryptoHash);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public void ReplayInputsLock_ComputesStableHash()
|
||||
{
|
||||
var manifest = ReplayManifest.Create(
|
||||
@@ -38,7 +40,8 @@ public class ReplayInputsLockTests
|
||||
Assert.Equal(lock1.ComputeHash(_hasher), lock2.ComputeHash(_hasher));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public void ReplayInputsLock_TracksManifestHash()
|
||||
{
|
||||
var manifest = ReplayManifest.Create(
|
||||
|
||||
@@ -3,6 +3,7 @@ using StellaOps.Cryptography;
|
||||
using StellaOps.Orchestrator.Core.Domain.Replay;
|
||||
using StellaOps.Orchestrator.Core.Hashing;
|
||||
|
||||
using StellaOps.TestKit;
|
||||
namespace StellaOps.Orchestrator.Tests;
|
||||
|
||||
public class ReplayManifestTests
|
||||
@@ -15,7 +16,8 @@ public class ReplayManifestTests
|
||||
_hasher = new CanonicalJsonHasher(_cryptoHash);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public void ComputeHash_IsStableWithCanonicalOrdering()
|
||||
{
|
||||
var inputs = new ReplayInputs(
|
||||
|
||||
@@ -4,6 +4,8 @@ using StellaOps.Cryptography;
|
||||
using StellaOps.Orchestrator.Core;
|
||||
using StellaOps.Orchestrator.Core.Hashing;
|
||||
|
||||
|
||||
using StellaOps.TestKit;
|
||||
namespace StellaOps.Orchestrator.Tests;
|
||||
|
||||
public class SchemaSmokeTests
|
||||
@@ -16,7 +18,8 @@ public class SchemaSmokeTests
|
||||
_hasher = new CanonicalJsonHasher(_cryptoHash);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Theory]
|
||||
[InlineData("event-envelope.schema.json")]
|
||||
[InlineData("audit-bundle.schema.json")]
|
||||
[InlineData("replay-manifest.schema.json")]
|
||||
@@ -33,7 +36,8 @@ public class SchemaSmokeTests
|
||||
Assert.True(doc.RootElement.TryGetProperty("title", out _));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public void CanonicalHash_For_EventEnvelope_IsStable()
|
||||
{
|
||||
var envelope = EventEnvelope.Create(
|
||||
|
||||
@@ -133,6 +133,7 @@
|
||||
|
||||
|
||||
|
||||
<ProjectReference Include="../../../__Libraries/StellaOps.TestKit/StellaOps.TestKit.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user