test(OpenCode TLS): 覆蓋預設跳過驗證行為

This commit is contained in:
2026-06-20 13:56:00 +00:00
parent 9d759464c2
commit 648334d153
3 changed files with 41 additions and 5 deletions
+16 -2
View File
@@ -183,10 +183,9 @@ describe('verifyLLM', () => {
assert.deepEqual(urls, ['http://opencode.local:4096/global/health', 'http://opencode.local:4096/config/providers']);
});
it('passes an insecure https agent for opencode when TLS verification is disabled', async () => {
it('passes an insecure https agent for opencode by default', 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);
@@ -200,6 +199,21 @@ describe('verifyLLM', () => {
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';
process.env.OPENCODE_SKIP_TLS_VERIFY = 'false';
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.deepEqual(agents, [undefined, undefined]);
});
it('checks openai GPT-5.5 with Responses API', async () => {
clearLLMEnv();
process.env.OPENAI_API_KEY = 'sk-test';