From a60fb8d168999893778df1ff65021507382592c7 Mon Sep 17 00:00:00 2001 From: Jeffery Date: Mon, 22 Jun 2026 10:01:27 +0000 Subject: [PATCH] =?UTF-8?q?test(OpenCode=20TLS):=20=E8=A3=9C=E9=BD=8A?= =?UTF-8?q?=E8=B7=B3=E9=81=8E=E9=A9=97=E8=AD=89=E8=A8=AD=E5=AE=9A=E6=B8=AC?= =?UTF-8?q?=E8=A9=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/config.test.js | 7 +++++++ app/preflight.test.js | 17 +++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/app/config.test.js b/app/config.test.js index dec24c9..8f43e5a 100644 --- a/app/config.test.js +++ b/app/config.test.js @@ -114,6 +114,13 @@ describe('getLLMConfig', () => { assert.equal(shouldSkipOpenCodeTLSVerify(), false); }); + it('skips OpenCode TLS verification for empty string and non-false values', () => { + for (const value of ['', '0', 'true', 'yes']) { + process.env.OPENCODE_SKIP_TLS_VERIFY = value; + assert.equal(shouldSkipOpenCodeTLSVerify(), true); + } + }); + it('openai takes priority over gemini when both set', () => { process.env.OPENAI_API_KEY = 'sk-test'; process.env.GEMINI_API_KEY = 'gemini-key'; diff --git a/app/preflight.test.js b/app/preflight.test.js index 0270c33..6cc0d33 100644 --- a/app/preflight.test.js +++ b/app/preflight.test.js @@ -199,6 +199,23 @@ describe('verifyLLM', () => { assert.equal(agents[1].options.rejectUnauthorized, false); }); + it('passes an insecure https agent for opencode when TLS skip is explicitly true', async () => { + clearLLMEnv(); + process.env.OPENCODE_BASE_URL = 'https://opencode.local:4096'; + process.env.OPENCODE_SKIP_TLS_VERIFY = 'true'; + const agents = []; + mock.method(axios, 'get', async (url, opts) => { + agents.push(opts.httpsAgent); + if (url.endsWith('/global/health')) return { data: { healthy: true } }; + return { data: { providers: [{ id: 'google', models: { 'gemini-2.5-flash': { id: 'gemini-2.5-flash' } } }] } }; + }); + const result = await verifyLLM(); + assert.equal(result.ok, true); + assert.equal(agents.length, 2); + assert.equal(agents[0].options.rejectUnauthorized, false); + assert.equal(agents[1].options.rejectUnauthorized, false); + }); + it('does not pass an insecure https agent for opencode when TLS verification is enabled', async () => { clearLLMEnv(); process.env.OPENCODE_BASE_URL = 'https://opencode.local:4096';