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
+14 -2
View File
@@ -164,9 +164,8 @@ describe('chat - key rotation', async () => {
assert.equal(headers[0]['Authorization'], `Basic ${Buffer.from('opencode:secret').toString('base64')}`);
});
it('passes an insecure https agent to OpenCode when TLS verification is disabled', async () => {
it('passes an insecure https agent to OpenCode by default', async () => {
process.env.OPENCODE_BASE_URL = 'https://opencode.local:4096';
process.env.OPENCODE_SKIP_TLS_VERIFY = 'true';
const agents = [];
mock.method(axios, 'post', async (url, _payload, opts) => {
agents.push(opts.httpsAgent);
@@ -179,6 +178,19 @@ describe('chat - key rotation', async () => {
assert.equal(agents[1].options.rejectUnauthorized, false);
});
it('does not pass an insecure https agent to OpenCode when TLS verification is enabled', async () => {
process.env.OPENCODE_BASE_URL = 'https://opencode.local:4096';
process.env.OPENCODE_SKIP_TLS_VERIFY = 'false';
const agents = [];
mock.method(axios, 'post', async (url, _payload, opts) => {
agents.push(opts.httpsAgent);
if (url.endsWith('/session')) return { data: { id: 'ses_test' } };
return { data: { parts: [{ type: 'text', text: 'ok' }] } };
});
await chat('sys', 'user');
assert.deepEqual(agents, [undefined, undefined]);
});
it('uses Responses API for openai GPT-5.5', async () => {
process.env.OPENAI_API_KEY = 'sk-test';
process.env.OPENAI_MODEL = 'GPT-5.5';