From de0db5a7778f504f3cdbaa2c2d8b47a9d3c6f254 Mon Sep 17 00:00:00 2001 From: Diego Rodrigues de Sa e Souza <8016841+diegosouzapw@users.noreply.github.com> Date: Tue, 14 Jul 2026 21:13:58 -0300 Subject: [PATCH] fix: include proxyId when testing a saved registry proxy (#7080) (#7189) --- ...080-proxy-test-connection-saved-proxyid.md | 1 + src/shared/components/ProxyConfigModal.tsx | 4 +- .../components/ProxyConfigModal.test.tsx | 63 +++++++++++++++++++ 3 files changed, 67 insertions(+), 1 deletion(-) create mode 100644 changelog.d/fixes/7080-proxy-test-connection-saved-proxyid.md diff --git a/changelog.d/fixes/7080-proxy-test-connection-saved-proxyid.md b/changelog.d/fixes/7080-proxy-test-connection-saved-proxyid.md new file mode 100644 index 0000000000..cc374b6a8a --- /dev/null +++ b/changelog.d/fixes/7080-proxy-test-connection-saved-proxyid.md @@ -0,0 +1 @@ +- fix(dashboard): include proxyId when testing a saved registry proxy so SOCKS5/auth credentials are loaded (#7080) diff --git a/src/shared/components/ProxyConfigModal.tsx b/src/shared/components/ProxyConfigModal.tsx index 9e7f561dc8..d1ab8a45a5 100644 --- a/src/shared/components/ProxyConfigModal.tsx +++ b/src/shared/components/ProxyConfigModal.tsx @@ -463,6 +463,7 @@ export default function ProxyConfigModal({ username?: string; password?: string; } | null = null; + let testProxyId: string | null = null; if (mode === "saved") { if (!selectedProxyId) { @@ -481,6 +482,7 @@ export default function ProxyConfigModal({ host: found.host || "", port: String(found.port || 8080), }; + testProxyId = selectedProxyId; } else { if (!String(host || "").trim()) { setTesting(false); @@ -498,7 +500,7 @@ export default function ProxyConfigModal({ const res = await fetch("/api/settings/proxy/test", { method: "POST", headers: { "Content-Type": "application/json" }, - body: JSON.stringify({ proxy }), + body: JSON.stringify(testProxyId ? { proxy, proxyId: testProxyId } : { proxy }), }); const data = await res.json().catch(() => ({})); if (!res.ok) { diff --git a/tests/unit/shared/components/ProxyConfigModal.test.tsx b/tests/unit/shared/components/ProxyConfigModal.test.tsx index 12299359d1..a63ebe9801 100644 --- a/tests/unit/shared/components/ProxyConfigModal.test.tsx +++ b/tests/unit/shared/components/ProxyConfigModal.test.tsx @@ -389,3 +389,66 @@ describe("ProxyConfigModal custom registry saves", () => { ).toBe(false); }); }); + +describe("ProxyConfigModal test connection (saved proxy)", () => { + beforeEach(() => { + ( + globalThis as typeof globalThis & { IS_REACT_ACT_ENVIRONMENT?: boolean } + ).IS_REACT_ACT_ENVIRONMENT = true; + fetchCalls = []; + }); + + afterEach(() => { + while (cleanupCallbacks.length > 0) { + cleanupCallbacks.pop()?.(); + } + document.body.innerHTML = ""; + vi.unstubAllGlobals(); + vi.restoreAllMocks(); + }); + + it("includes proxyId when testing a saved SOCKS5 registry proxy so the server can load its stored credentials", async () => { + installFetchMock((url, init) => { + const method = String(init?.method || "GET").toUpperCase(); + if (method === "GET" && url === "/api/settings/proxies") { + return { + body: { + items: [ + { + id: "socks5-1", + name: "Geonode SOCKS5", + type: "socks5", + host: "proxy.geonode.io", + port: 12000, + username: "***", + password: "***", + source: "manual", + }, + ], + total: 1, + socks5Enabled: true, + }, + }; + } + if (url.startsWith("/api/settings/proxies/assignments?") && url.includes("scope=provider")) { + return { + body: { items: [{ proxyId: "socks5-1", scope: "provider", scopeId: "claude" }], total: 1 }, + }; + } + if (method === "POST" && url === "/api/settings/proxy/test") { + return { body: { success: true, publicIp: "1.2.3.4", latencyMs: 500 } }; + } + return defaultProxyConfigResponses(url) || { status: 404, body: {} }; + }); + + const { container } = await renderProxyConfigModal(); + await clickButton(container, "testConnection"); + await waitForCall((call) => call.method === "POST" && call.url === "/api/settings/proxy/test"); + + const testCall = fetchCalls.find( + (call) => call.method === "POST" && call.url === "/api/settings/proxy/test" + ); + expect(testCall).toBeTruthy(); + expect(testCall?.body?.proxyId).toBe("socks5-1"); + }, 20000); +});