You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maka.apache.org by as...@apache.org on 2026/08/24 19:01:38 UTC
(maka) branch main updated: fix(desktop): preserve proxy auth intent in tests (#3683)
This is an automated email from the ASF dual-hosted git repository.
Astro-Han pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/maka.git
The following commit(s) were added to refs/heads/main by this push:
new 53aa7bd57 fix(desktop): preserve proxy auth intent in tests (#3683)
53aa7bd57 is described below
commit 53aa7bd5783dbbc87197469edf1b870da92c1a20
Author: ooopSok <81...@users.noreply.github.com>
AuthorDate: Tue Aug 25 03:01:33 2026 +0800
fix(desktop): preserve proxy auth intent in tests (#3683)
* fix(desktop): preserve proxy auth intent in tests
Generated-by: OpenAI Codex
* chore: retrigger CI
---
.../runtime-host-settings-ipc-main.test.ts | 97 ++++++++++++++++++++++
.../src/main/runtime-host-settings-ipc-main.ts | 7 +-
.../renderer/settings/general-settings-page.tsx | 1 +
packages/core/src/settings/network-settings.ts | 6 +-
4 files changed, 107 insertions(+), 4 deletions(-)
diff --git a/apps/desktop/src/main/__tests__/runtime-host-settings-ipc-main.test.ts b/apps/desktop/src/main/__tests__/runtime-host-settings-ipc-main.test.ts
new file mode 100644
index 000000000..b11c39fc5
--- /dev/null
+++ b/apps/desktop/src/main/__tests__/runtime-host-settings-ipc-main.test.ts
@@ -0,0 +1,97 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import assert from "node:assert/strict";
+import test from "node:test";
+import {
+ createDefaultRuntimePolicy,
+ type RuntimePolicy,
+} from "@maka/core/runtime-policy";
+import { registerRuntimeHostSettingsIpc } from "../runtime-host-settings-ipc-main.js";
+
+type TestCandidate = RuntimePolicy["networkProxy"];
+
+async function testCandidate(authEnabled: boolean): Promise<{
+ candidate: TestCandidate;
+ result: { ok: boolean; code: string };
+}> {
+ const handlers = new Map<string, (...args: unknown[]) => unknown>();
+ const policy = createDefaultRuntimePolicy();
+ let candidate: TestCandidate | undefined;
+
+ registerRuntimeHostSettingsIpc({
+ ipcMain: {
+ handle(channel, listener) {
+ handlers.set(channel, listener as (...args: unknown[]) => unknown);
+ },
+ },
+ client: {
+ async queryRuntimePolicy() {
+ return { revision: 0, policy };
+ },
+ async testNetworkProxy(input: { networkProxy?: TestCandidate }) {
+ candidate = input.networkProxy;
+ return candidate?.authEnabled
+ ? {
+ ok: false,
+ latencyMs: 0,
+ error: "Proxy credential is not configured",
+ }
+ : { ok: true, latencyMs: 1, status: 200 };
+ },
+ } as never,
+ settingsStore: {} as never,
+ async applyClientSettings() {},
+ });
+
+ const handler = handlers.get("settings:testNetworkProxy");
+ assert.ok(handler);
+ const result = await handler({}, {
+ proxy: {
+ enabled: true,
+ type: "http",
+ host: "127.0.0.1",
+ port: 7897,
+ authEnabled,
+ bypassList: [],
+ },
+ });
+
+ assert.ok(candidate);
+ return {
+ candidate,
+ result: result as { ok: boolean; code: string },
+ };
+}
+
+test("proxy test preserves enabled authentication when credentials are empty", async () => {
+ const tested = await testCandidate(true);
+
+ assert.equal(tested.candidate.authEnabled, true);
+ assert.equal(tested.result.ok, false);
+ assert.equal(tested.result.code, "proxy_unreachable");
+});
+
+test("proxy test preserves disabled authentication for a local proxy", async () => {
+ const tested = await testCandidate(false);
+
+ assert.equal(tested.candidate.authEnabled, false);
+ assert.equal(tested.result.ok, true);
+ assert.equal(tested.result.code, "proxy_reachable");
+});
diff --git a/apps/desktop/src/main/runtime-host-settings-ipc-main.ts b/apps/desktop/src/main/runtime-host-settings-ipc-main.ts
index d3edb27cc..f7b606594 100644
--- a/apps/desktop/src/main/runtime-host-settings-ipc-main.ts
+++ b/apps/desktop/src/main/runtime-host-settings-ipc-main.ts
@@ -30,8 +30,8 @@ import type {
} from "@maka/core/runtime-policy";
import { SENSITIVE_PLACEHOLDER } from "@maka/core/settings/network-settings";
import type {
- ProxySettings,
TestProxyInput,
+ TestProxySettings,
} from "@maka/core/settings/network-settings";
import type { SettingsStore } from "@maka/storage/settings-store";
import {
@@ -149,11 +149,12 @@ export async function updateRuntimeHostSettings(
}
function toRuntimeHostProxyPolicy(
- proxy: ProxySettings,
+ proxy: TestProxySettings,
autoBypassDomains: readonly string[],
): RuntimePolicy["networkProxy"] {
const username = proxy.username?.trim() ?? "";
- const authEnabled = Boolean(username || proxy.password);
+ const authEnabled =
+ proxy.authEnabled ?? Boolean(username || proxy.password);
return {
enabled: proxy.enabled,
protocol: proxy.type,
diff --git a/apps/desktop/src/renderer/settings/general-settings-page.tsx b/apps/desktop/src/renderer/settings/general-settings-page.tsx
index 8ad239bd6..40e48cb63 100644
--- a/apps/desktop/src/renderer/settings/general-settings-page.tsx
+++ b/apps/desktop/src/renderer/settings/general-settings-page.tsx
@@ -942,6 +942,7 @@ function toProxyTestInput(proxy: NetworkProxySettings): TestProxyInput {
type: proxy.protocol,
host: proxy.host.trim(),
port: proxy.port,
+ authEnabled: proxy.authEnabled,
username:
proxy.authEnabled && proxy.username.trim()
? proxy.username.trim()
diff --git a/packages/core/src/settings/network-settings.ts b/packages/core/src/settings/network-settings.ts
index ff0883663..51d044d35 100644
--- a/packages/core/src/settings/network-settings.ts
+++ b/packages/core/src/settings/network-settings.ts
@@ -68,8 +68,12 @@ export const NETWORK_DEFAULTS: RuntimeNetworkSettings = {
preferIpv4: false,
};
+export interface TestProxySettings extends ProxySettings {
+ authEnabled?: boolean;
+}
+
export interface TestProxyInput {
- proxy?: ProxySettings;
+ proxy?: TestProxySettings;
url?: string;
timeoutMs?: number;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org