mirror of
https://github.com/fawney19/Aether.git
synced 2026-09-01 17:00:21 +08:00
feat: ProxyNode 代理节点管理系统与 OpenAI Responses API 解析增强
ProxyNode 系统:新增 aether-proxy(Rust)海外 VPS 代理组件,后端实现节点注册/心跳/ HMAC 认证/健康检测调度器/模块化集成,前端新增代理节点管理页面。ProxyConfig 支持 node_id 模式,http_client 支持 HMAC 签名代理 URL 构建与 TTL 缓存。 OpenAI CLI 解析器:适配 Responses API 格式,支持 input_tokens/output_tokens 提取、 output[].content[].text 文本解析、response.completed 流式事件 usage 嵌套结构。
This commit is contained in:
35
tests/unit/test_proxy_config.py
Normal file
35
tests/unit/test_proxy_config.py
Normal file
@@ -0,0 +1,35 @@
|
||||
import pytest
|
||||
from pydantic import ValidationError
|
||||
|
||||
from src.models.admin_requests import ProxyConfig
|
||||
|
||||
|
||||
class TestProxyConfig:
|
||||
def test_enabled_requires_url_or_node_id(self) -> None:
|
||||
with pytest.raises(ValidationError):
|
||||
ProxyConfig.model_validate({"enabled": True})
|
||||
|
||||
def test_enabled_rejects_both_url_and_node_id(self) -> None:
|
||||
with pytest.raises(ValidationError):
|
||||
ProxyConfig.model_validate(
|
||||
{"enabled": True, "url": "http://127.0.0.1:8080", "node_id": "n1"}
|
||||
)
|
||||
|
||||
def test_disabled_allows_empty(self) -> None:
|
||||
cfg = ProxyConfig.model_validate({"enabled": False})
|
||||
assert cfg.url is None
|
||||
assert cfg.node_id is None
|
||||
|
||||
def test_url_mode_ok(self) -> None:
|
||||
cfg = ProxyConfig.model_validate({"enabled": True, "url": "http://127.0.0.1:8080"})
|
||||
assert cfg.url == "http://127.0.0.1:8080"
|
||||
assert cfg.node_id is None
|
||||
|
||||
def test_url_rejects_inline_auth(self) -> None:
|
||||
with pytest.raises(ValidationError):
|
||||
ProxyConfig.model_validate({"enabled": True, "url": "http://u:p@127.0.0.1:8080"})
|
||||
|
||||
def test_node_id_mode_ok_and_strips(self) -> None:
|
||||
cfg = ProxyConfig.model_validate({"enabled": True, "node_id": " node-1 "})
|
||||
assert cfg.node_id == "node-1"
|
||||
assert cfg.url is None
|
||||
Reference in New Issue
Block a user