test(OpenCode TLS): 補齊跳過驗證設定測試

This commit is contained in:
2026-06-22 10:01:49 +00:00
parent 995a62e04d
commit a60fb8d168
2 changed files with 24 additions and 0 deletions
+7
View File
@@ -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';
+17
View File
@@ -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';