From fb1a5a2c264d77b7c7321bd61b18e98ba53acd36 Mon Sep 17 00:00:00 2001 From: SARAMALI15792 Date: Mon, 20 Apr 2026 23:01:45 +0500 Subject: [PATCH] test(gateway): assert cli_container_local precedence over loopback fallback (#69397) --- .../handshake-auth-helpers.test.ts | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/gateway/server/ws-connection/handshake-auth-helpers.test.ts b/src/gateway/server/ws-connection/handshake-auth-helpers.test.ts index 907c74745e4..bcb111f5e41 100644 --- a/src/gateway/server/ws-connection/handshake-auth-helpers.test.ts +++ b/src/gateway/server/ws-connection/handshake-auth-helpers.test.ts @@ -548,4 +548,25 @@ describe("handshake auth helpers", () => { }), ).toBe(false); }); + + it("prefers cli_container_local over shared_secret_loopback_local for CLI clients", () => { + const connectParams = { + client: { + id: GATEWAY_CLIENT_IDS.CLI, + mode: GATEWAY_CLIENT_MODES.CLI, + }, + } as ConnectParams; + expect( + resolvePairingLocality({ + connectParams, + isLocalClient: false, + requestHost: "127.0.0.1:18789", + remoteAddress: "127.0.0.1", + hasProxyHeaders: false, + hasBrowserOriginHeader: false, + sharedAuthOk: true, + authMethod: "token", + }), + ).toBe("cli_container_local"); + }); });