mirror of
https://github.com/fawney19/Aether.git
synced 2026-09-02 17:30:23 +08:00
feat(codex): 增强 OAuth 导入解析与账号信息提取,优化维护调度器线程模型
Codex OAuth: - 导入解析支持附加账号字段(account_id/plan_type/user_id/email) - enrich_codex 扩展从 access_token 和直接字段提取账号信息 - parse_codex_id_token 支持 JWT/JSON 字符串/dict 三种输入格式 - request patching 新增 openai:compact 格式支持 - codex_usage_parser 新增 credits_unlimited 字段解析 维护调度器: - 同步 DB 操作迁移到线程池执行,避免阻塞事件循环 - 新增 request_candidates 定期清理任务 - 新增每周 VACUUM ANALYZE 数据库表维护任务 - 新增 enable_db_maintenance 配置项 前端: - ElapsedTimeText 从 setInterval 改为 requestAnimationFrame - 时间线过滤 available/unused 占位记录 - Usage 页面默认关闭全局自动刷新 - 移除号池管理中的配额更新时间显示
This commit is contained in:
45
tests/unit/test_provider_oauth_import_parser.py
Normal file
45
tests/unit/test_provider_oauth_import_parser.py
Normal file
@@ -0,0 +1,45 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from src.api.admin import provider_oauth as module
|
||||
|
||||
|
||||
def test_parse_standard_oauth_import_entries_keeps_codex_hints() -> None:
|
||||
entries = module._parse_standard_oauth_import_entries(
|
||||
'[{"refresh_token":"rt_1","accountId":"acc-1","planType":"TEAM","userId":"u-1","email":"u@example.com"}]'
|
||||
)
|
||||
|
||||
assert entries == [
|
||||
{
|
||||
"refresh_token": "rt_1",
|
||||
"account_id": "acc-1",
|
||||
"plan_type": "team",
|
||||
"user_id": "u-1",
|
||||
"email": "u@example.com",
|
||||
}
|
||||
]
|
||||
|
||||
|
||||
def test_parse_tokens_input_compatibility_wrapper() -> None:
|
||||
tokens = module._parse_tokens_input("token_a\ntoken_b")
|
||||
assert tokens == ["token_a", "token_b"]
|
||||
|
||||
|
||||
def test_apply_codex_import_hints_only_fills_missing_fields() -> None:
|
||||
auth_config = {
|
||||
"account_id": "existing-account",
|
||||
"plan_type": "",
|
||||
}
|
||||
module._apply_codex_import_hints(
|
||||
auth_config,
|
||||
{
|
||||
"account_id": "acc-1",
|
||||
"plan_type": "plus",
|
||||
"user_id": "user-1",
|
||||
"email": "u@example.com",
|
||||
},
|
||||
)
|
||||
|
||||
assert auth_config["account_id"] == "existing-account"
|
||||
assert auth_config["plan_type"] == "plus"
|
||||
assert auth_config["user_id"] == "user-1"
|
||||
assert auth_config["email"] == "u@example.com"
|
||||
Reference in New Issue
Block a user