test(OpenCode TLS): 補齊非 false 值驗證
AI / 計算版本號 (pull_request) Successful in 2s
AI / Code Review (pull_request) Failing after 1m17s

This commit is contained in:
2026-06-22 10:21:53 +00:00
parent 4dc50941b0
commit ca6b066a52
3 changed files with 20 additions and 32 deletions
+1 -1
View File
@@ -115,7 +115,7 @@ describe('getLLMConfig', () => {
});
it('skips OpenCode TLS verification for empty string and non-false values', () => {
for (const value of ['', '0', 'true', 'yes']) {
for (const value of ['', '0', 'true', 'yes', '1', 'on', 'custom']) {
process.env.OPENCODE_SKIP_TLS_VERIFY = value;
assert.equal(shouldSkipOpenCodeTLSVerify(), true);
}
+18 -15
View File
@@ -199,21 +199,24 @@ 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('passes an insecure https agent for opencode when TLS skip is any non-false value', async () => {
for (const value of ['true', '', '0', 'yes', '1', 'on']) {
clearLLMEnv();
mock.restoreAll();
process.env.OPENCODE_BASE_URL = 'https://opencode.local:4096';
process.env.OPENCODE_SKIP_TLS_VERIFY = value;
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 () => {