* chore(release): stop publishing legacy Windows update packages * feat(agents): support OpenCode Desktop across platforms Detect CLI and desktop installations on Windows, macOS, and Linux, and add separate launch and restart controls. Closes #156 * fix(codex): align model display names and show total session count - preserve runtime model identity in generated catalogs - count distinct sessions across database and rollout sources - update session count labels in all supported languages * fix(codex): keep config and auth files in sync - generate auth.json for API key configuration - preserve and validate OAuth credentials - include auth.json in transactional updates and rollback - retain compatibility with legacy Codex configuration states * fix(cpa-gui): update version to 0.2.59 in Cargo files * fix(codex): preserve OAuth mode after closing configuration * feat(config): add TLS management and protocol-aware local URLs - add TLS controls to advanced settings - persist certificate and private key paths - restart the core after TLS changes - switch WebUI, API and management URLs between HTTP and HTTPS - synchronize agent configurations and detection with the active protocol * refactor(config): reorganize network, routing, and TLS settings - split network settings and session routing into separate tabs - move TLS configuration into network settings - preserve TLS restart and HTTPS URL synchronization behavior * feat(config): add independent network settings and custom listen IP * fix(navigation): allow access to usage records while core is stopped * refactor(home): show a single API URL based on the configured listen IP * feat(config): add file pickers for TLS certificate and private key
60 lines
2.2 KiB
TypeScript
60 lines
2.2 KiB
TypeScript
import { describe, expect, it } from 'bun:test';
|
|
import { clientApiProfiles, webUiManagementUrl } from '../src/services/clientAccess';
|
|
|
|
describe('客户端 API 接入信息', () => {
|
|
it('生成 OpenAI、Claude 和 Gemini 三种正确格式', () => {
|
|
const profiles = clientApiProfiles(9527);
|
|
|
|
expect(profiles.map((profile) => profile.id)).toEqual(['openai', 'claude', 'gemini']);
|
|
expect(profiles[0].baseUrl).toBe('http://127.0.0.1:9527/v1');
|
|
expect(profiles[1].baseUrl).toBe('http://127.0.0.1:9527');
|
|
expect(profiles[2].baseUrl).toBe('http://127.0.0.1:9527');
|
|
});
|
|
|
|
it('端口无效时回退到 8317,缺少局域网地址时保持为空', () => {
|
|
const [openai] = clientApiProfiles(0);
|
|
|
|
expect(openai.baseUrl).toBe('http://127.0.0.1:8317/v1');
|
|
});
|
|
|
|
it('TLS 开启时生成 HTTPS 客户端地址', () => {
|
|
const profiles = clientApiProfiles(9527, true);
|
|
|
|
expect(profiles[0].baseUrl).toBe('https://127.0.0.1:9527/v1');
|
|
expect(profiles[1].baseUrl).toBe('https://127.0.0.1:9527');
|
|
});
|
|
|
|
it('使用当前内核端口生成 WebUI 登录地址', () => {
|
|
expect(webUiManagementUrl(9527)).toBe(
|
|
'http://127.0.0.1:9527/management.html#/login',
|
|
);
|
|
expect(webUiManagementUrl(0)).toBe(
|
|
'http://127.0.0.1:8317/management.html#/login',
|
|
);
|
|
expect(webUiManagementUrl(9527, true)).toBe(
|
|
'https://127.0.0.1:9527/management.html#/login',
|
|
);
|
|
});
|
|
|
|
it('uses the configured listen IP for API and WebUI URLs', () => {
|
|
const [openai] = clientApiProfiles(9527, true, '192.168.1.20');
|
|
|
|
expect(openai.baseUrl).toBe('https://192.168.1.20:9527/v1');
|
|
expect(webUiManagementUrl(9527, true, '192.168.1.20')).toBe(
|
|
'https://192.168.1.20:9527/management.html#/login',
|
|
);
|
|
});
|
|
|
|
it('converts wildcard and IPv6 listen IPs to connectable URL hosts', () => {
|
|
expect(webUiManagementUrl(8317, false, '0.0.0.0')).toBe(
|
|
'http://127.0.0.1:8317/management.html#/login',
|
|
);
|
|
expect(webUiManagementUrl(8317, false, '::')).toBe(
|
|
'http://[::1]:8317/management.html#/login',
|
|
);
|
|
expect(clientApiProfiles(8317, false, '2001:db8::1')[0].baseUrl).toBe(
|
|
'http://[2001:db8::1]:8317/v1',
|
|
);
|
|
});
|
|
});
|