feat: harden gateway reply remap and leaf loop transparency
This commit is contained in:
19
tests/NATS.Server.Tests/GatewayAdvancedRemapRuntimeTests.cs
Normal file
19
tests/NATS.Server.Tests/GatewayAdvancedRemapRuntimeTests.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
using NATS.Server.Gateways;
|
||||
|
||||
namespace NATS.Server.Tests;
|
||||
|
||||
public class GatewayAdvancedRemapRuntimeTests
|
||||
{
|
||||
[Fact]
|
||||
public void Transport_internal_reply_and_loop_markers_never_leak_to_client_visible_subjects()
|
||||
{
|
||||
const string clientReply = "_INBOX.123";
|
||||
var nested = ReplyMapper.ToGatewayReply(
|
||||
ReplyMapper.ToGatewayReply(clientReply, "CLUSTER-A"),
|
||||
"CLUSTER-B");
|
||||
|
||||
ReplyMapper.TryRestoreGatewayReply(nested, out var restored).ShouldBeTrue();
|
||||
restored.ShouldBe(clientReply);
|
||||
restored.ShouldNotStartWith("_GR_.");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
using NATS.Server.LeafNodes;
|
||||
|
||||
namespace NATS.Server.Tests.LeafNodes;
|
||||
|
||||
public class LeafLoopTransparencyRuntimeTests
|
||||
{
|
||||
[Fact]
|
||||
public void Transport_internal_reply_and_loop_markers_never_leak_to_client_visible_subjects()
|
||||
{
|
||||
var nested = LeafLoopDetector.Mark(
|
||||
LeafLoopDetector.Mark("orders.created", "S1"),
|
||||
"S2");
|
||||
|
||||
LeafLoopDetector.TryUnmark(nested, out var unmarked).ShouldBeTrue();
|
||||
unmarked.ShouldBe("orders.created");
|
||||
unmarked.ShouldNotStartWith("$LDS.");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user