Add CultMesh authority lease checks

This commit is contained in:
Meta Vens 2026-05-20 01:49:18 +01:00
commit e5e993e7aa
7 changed files with 211 additions and 0 deletions

View file

@ -1020,6 +1020,35 @@ namespace GameCult.Networking.Tests
Assert.That(updates, Has.Count.EqualTo(1));
}
[Test]
public void CultMeshAuthorityLeaseCatalog_Authorizes_PeerRoleAndShard()
{
var now = DateTimeOffset.Parse("2026-05-20T12:00:00.0000000Z");
var catalog = CultMesh.CreateAuthorityLeaseCatalog();
var peer = new CultMeshPeerCard(
"peer-primary",
"aetheria-main",
["cultnet://primary.example.test:3075"],
roles: [CultMeshPeerRoles.ShardPrimary],
shardIds: ["players-us-east"],
authorityLeaseId: "lease-primary");
catalog.Upsert(new CultMeshAuthorityLease(
"lease-primary",
"aetheria-main",
"peer-primary",
[CultMeshPeerRoles.ShardPrimary],
["players-us-east"],
"gc-operator",
now.AddMinutes(-5),
now.AddMinutes(5),
signature: "sig"));
Assert.That(catalog.IsAuthorized(peer, CultMeshPeerRoles.ShardPrimary, "players-us-east", now), Is.True);
Assert.That(catalog.IsAuthorized(peer, CultMeshPeerRoles.ShardPrimary, "players-eu", now), Is.False);
Assert.That(catalog.IsAuthorized(peer, CultMeshPeerRoles.ReadReplica, "players-us-east", now), Is.False);
Assert.That(catalog.IsAuthorized(peer, CultMeshPeerRoles.ShardPrimary, "players-us-east", now.AddMinutes(6)), Is.False);
}
[Test]
public async Task CultMeshNode_CanEnable_DurableShardLogs_WithDefaultPath()
{