From 71e3bb1f01466fc1a50e6578df39653c14994c60 Mon Sep 17 00:00:00 2001 From: samosvalishe Date: Thu, 21 May 2026 01:33:20 +0300 Subject: [PATCH] =?UTF-8?q?test(bondserver):=20=D1=82=D0=B5=D1=81=D1=82=20?= =?UTF-8?q?=D0=B8=D0=B7=D0=BE=D0=BB=D1=8F=D1=86=D0=B8=D0=B8=20tenant?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Защищает от регрессии, где ключ map Registry откатывается с {Tenant, ConnID} к голому ConnID. Один и тот же ConnID под двумя TenantID должен резолвиться в разные serverConn. --- internal/proxy/bondserver/bondserver_test.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/internal/proxy/bondserver/bondserver_test.go b/internal/proxy/bondserver/bondserver_test.go index bce516e..0fb3047 100644 --- a/internal/proxy/bondserver/bondserver_test.go +++ b/internal/proxy/bondserver/bondserver_test.go @@ -273,3 +273,22 @@ func TestRegistryGetDedup(t *testing.T) { } t.Fatal("registry did not drop conn after done") } + +// TestRegistryTenantIsolation ensures that the same ConnID under different +// tenant scopes resolves to distinct serverConn instances. Guards against a +// regression where the map key reverts to plain uint64. +func TestRegistryTenantIsolation(t *testing.T) { + r := NewRegistry(Deps{}) + ctx := t.Context() + + ca := r.get(ctx, auth.TenantID("A"), 7, "127.0.0.1:1") + cb := r.get(ctx, auth.TenantID("B"), 7, "127.0.0.1:1") + if ca == cb { + t.Fatal("expected distinct conns for different tenants on same ConnID") + } + if ca.tenantID != auth.TenantID("A") || cb.tenantID != auth.TenantID("B") { + t.Fatalf("tenantID mismatch: ca=%q cb=%q", ca.tenantID, cb.tenantID) + } + close(ca.done) + close(cb.done) +}