- 导入callDeployControl和normalizeTokenResponse函数用于处理部署配置 - 新增hasTargetFrontendUrl函数检查响应中是否存在目标前端URL - 在注册流程中添加部署路由解析逻辑,当缺少前端URL时调用部署控制服务获取配置 - 更新normalizeTokenResponse函数以支持从实例对象中提取URL配置 refactor(runtime-control): 增强令牌响应标准化功能 - 扩展normalizeTokenResponse函数支持从instance对象中获取URL配置 - 添加对instance字段的支持,优先级为routing > instance配置 - 支持从instance中提取frontend_base_url、api_base_url和public_url build(tsconfig): 排除测试文件构建 - 在tsconfig.json中添加排除规则,排除**/*.test.ts和**/*.test.tsx文件 - 避免测试文件参与生产构建 refactor(authz-service): 优化Python后端令牌响应处理 - 更新_normalize_portal_token_response函数支持从实例对象中提取URL配置 - 重构URL优先级逻辑,支持routing和instance双重数据源 - 改进代码可读性,将复杂的URL赋值逻辑拆分为多行
26 lines
816 B
TypeScript
26 lines
816 B
TypeScript
import { describe, expect, it } from 'vitest';
|
|
|
|
import { normalizeTokenResponse } from './runtime-control';
|
|
|
|
describe('normalizeTokenResponse', () => {
|
|
it('uses nested instance routing when top-level route URLs are missing', () => {
|
|
const response = normalizeTokenResponse({
|
|
access_token: 'token',
|
|
refresh_token: '',
|
|
token_type: 'bearer',
|
|
user_id: 'alice',
|
|
username: 'alice',
|
|
role: 'owner',
|
|
handoff_code: 'handoff-1',
|
|
}, {
|
|
instance: {
|
|
public_url: 'workspace.example.com:8088',
|
|
frontend_base_url: 'workspace.example.com:8088',
|
|
},
|
|
});
|
|
|
|
expect(response.backend_connection?.frontend_base_url).toBe('workspace.example.com:8088');
|
|
expect(response.backend_connection?.public_base_url).toBe('workspace.example.com:8088');
|
|
});
|
|
});
|