mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-07-26 09:52:11 +03:00
This commit is contained in:
committed by
GitHub
parent
ed1120efd5
commit
de0db5a777
@@ -0,0 +1 @@
|
||||
- fix(dashboard): include proxyId when testing a saved registry proxy so SOCKS5/auth credentials are loaded (#7080)
|
||||
@@ -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) {
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user