mirror of
https://github.com/fawney19/Aether.git
synced 2026-09-02 09:20:22 +08:00
- Antigravity 端点签名从 gemini:cli 统一为 gemini:chat,保留向后兼容,含 DB 迁移 - 流式处理中 usage/completion/text 提取抽离为 _update_ctx_from_provider_event, 支持 envelope 解包后提取,避免格式转换流程中重复计数 - 新增 has_format_conversion 属性,区分真正的格式转换与 envelope rewrite, 修正 usage 展示层的格式转换标记 - 请求详情抽屉对未完成请求支持自动轮询刷新,关闭时自动停止 - 按次计费样式调整;实际成本仅在倍率非 1.0 时显示;缓存日志降级为 trace
48 lines
1.3 KiB
Python
48 lines
1.3 KiB
Python
from __future__ import annotations
|
|
|
|
import json
|
|
import time
|
|
from types import SimpleNamespace
|
|
from unittest.mock import patch
|
|
|
|
import pytest
|
|
|
|
from src.api.handlers.base.request_builder import get_provider_auth
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_get_provider_auth_oauth_returns_decrypted_auth_config() -> None:
|
|
now = int(time.time())
|
|
token_meta = {
|
|
"provider_type": "antigravity",
|
|
"expires_at": now + 3600,
|
|
"refresh_token": "rt-1",
|
|
"project_id": "project-1",
|
|
}
|
|
|
|
endpoint = SimpleNamespace(api_format="gemini:chat")
|
|
key = SimpleNamespace(
|
|
id="k1",
|
|
auth_type="oauth",
|
|
api_key="enc_access",
|
|
auth_config="enc_cfg",
|
|
provider=None,
|
|
)
|
|
|
|
def _decrypt(v: str) -> str:
|
|
if v == "enc_access":
|
|
return "access-token"
|
|
if v == "enc_cfg":
|
|
return json.dumps(token_meta)
|
|
return ""
|
|
|
|
with patch(
|
|
"src.api.handlers.base.request_builder.crypto_service.decrypt", side_effect=_decrypt
|
|
):
|
|
auth = await get_provider_auth(endpoint, key) # type: ignore[arg-type]
|
|
|
|
assert auth is not None
|
|
assert auth.auth_header == "Authorization"
|
|
assert auth.auth_value == "Bearer access-token"
|
|
assert auth.decrypted_auth_config == token_meta
|