發布 AI review Review 統計與 Step9 合併阻擋調整 #30
@@ -114,6 +114,13 @@ describe('getLLMConfig', () => {
|
|||||||
assert.equal(shouldSkipOpenCodeTLSVerify(), false);
|
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', () => {
|
it('openai takes priority over gemini when both set', () => {
|
||||||
process.env.OPENAI_API_KEY = 'sk-test';
|
process.env.OPENAI_API_KEY = 'sk-test';
|
||||||
process.env.GEMINI_API_KEY = 'gemini-key';
|
process.env.GEMINI_API_KEY = 'gemini-key';
|
||||||
|
|||||||
@@ -199,6 +199,23 @@ describe('verifyLLM', () => {
|
|||||||
assert.equal(agents[1].options.rejectUnauthorized, false);
|
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 () => {
|
it('does not pass an insecure https agent for opencode when TLS verification is enabled', async () => {
|
||||||
clearLLMEnv();
|
clearLLMEnv();
|
||||||
process.env.OPENCODE_BASE_URL = 'https://opencode.local:4096';
|
process.env.OPENCODE_BASE_URL = 'https://opencode.local:4096';
|
||||||
|
|||||||
Reference in New Issue
Block a user