mirror of
https://github.com/fawney19/Aether.git
synced 2026-09-03 01:40:21 +08:00
feat(pool,priority): 号池聚合显示、API 格式归一化与优先级管理重构
- 优先级管理对话框按 family 分组显示 API 格式,号池 key 聚合为单条目展示 - 拖拽排序改用 key ID 替代数组索引,号池聚合项禁用拖拽/编辑/开关操作 - 后端 key 分组查询增加 API 格式键归一化,返回 provider_id - 提取 OAuth auth_config 解密逻辑,新增 _derive_oauth_expires_at 从加密配置派生过期时间 - 号池管理移除会话列,调整 OAuth 过期信息与刷新按钮的布局顺序
This commit is contained in:
40
tests/unit/test_pool_oauth_expires.py
Normal file
40
tests/unit/test_pool_oauth_expires.py
Normal file
@@ -0,0 +1,40 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from datetime import datetime, timezone
|
||||
from types import SimpleNamespace
|
||||
|
||||
from src.api.admin.pool import routes as pool_routes
|
||||
|
||||
|
||||
def test_derive_oauth_expires_at_from_auth_config_seconds(monkeypatch) -> None:
|
||||
key = SimpleNamespace(auth_type="oauth", auth_config="enc", expires_at=None)
|
||||
|
||||
monkeypatch.setattr(
|
||||
pool_routes.crypto_service,
|
||||
"decrypt",
|
||||
lambda _v: '{"expires_at": 1710000000}',
|
||||
)
|
||||
|
||||
assert pool_routes._derive_oauth_expires_at(key) == 1710000000
|
||||
|
||||
|
||||
def test_derive_oauth_expires_at_from_auth_config_milliseconds(monkeypatch) -> None:
|
||||
key = SimpleNamespace(auth_type="oauth", auth_config="enc", expires_at=None)
|
||||
|
||||
monkeypatch.setattr(
|
||||
pool_routes.crypto_service,
|
||||
"decrypt",
|
||||
lambda _v: '{"expires_at": 1710000000000}',
|
||||
)
|
||||
|
||||
assert pool_routes._derive_oauth_expires_at(key) == 1710000000
|
||||
|
||||
|
||||
def test_derive_oauth_expires_at_fallback_to_legacy_datetime() -> None:
|
||||
key = SimpleNamespace(
|
||||
auth_type="oauth",
|
||||
auth_config=None,
|
||||
expires_at=datetime(2026, 3, 4, 1, 2, 3, tzinfo=timezone.utc),
|
||||
)
|
||||
|
||||
assert pool_routes._derive_oauth_expires_at(key) == 1772586123
|
||||
Reference in New Issue
Block a user