test(batch7): implement t3 cross-cutting mapped tests

This commit is contained in:
Joseph Doherty
2026-02-28 11:32:36 -05:00
parent 007122a659
commit efc0d642b1
4 changed files with 144 additions and 0 deletions

View File

@@ -1,5 +1,9 @@
using System.Text;
using Shouldly;
using ZB.MOM.NatsNet.Server;
using ZB.MOM.NatsNet.Server.Auth;
using ZB.MOM.NatsNet.Server.Internal;
using ZB.MOM.NatsNet.Server.Internal.DataStructures;
namespace ZB.MOM.NatsNet.Server.Tests.ImplBacklog;
@@ -148,4 +152,51 @@ public sealed class ConfigReloaderTests
ServerOptions.NoErrOnUnknownFields(false);
}
}
[Fact] // T:2774
public void ConfigReloadAuthDoesNotBreakRouteInterest_ShouldSucceed()
{
var (server, createError) = NatsServer.NewServer(new ServerOptions
{
NoLog = true,
NoSigs = true,
Accounts = [new Account { Name = "A" }],
Users = [new User
{
Username = "u",
Password = "p",
Account = new Account { Name = "A" },
}],
});
createError.ShouldBeNull();
server.ShouldNotBeNull();
try
{
var (account, lookupError) = server!.LookupAccount("A");
lookupError.ShouldBeNull();
account.ShouldNotBeNull();
account!.Sublist = SubscriptionIndex.NewSublistWithCache();
var insertError = account.Sublist.Insert(new Subscription
{
Subject = Encoding.ASCII.GetBytes("foo"),
Queue = Encoding.ASCII.GetBytes("bar"),
});
insertError.ShouldBeNull();
account.TotalSubs().ShouldBe(1);
server.ReloadAuthorization();
var (updatedAccount, updatedLookupError) = server.LookupAccount("A");
updatedLookupError.ShouldBeNull();
updatedAccount.ShouldNotBeNull();
updatedAccount!.TotalSubs().ShouldBe(1);
}
finally
{
server!.Shutdown();
}
}
}