feat: 扩展 Rust gateway 全功能模块,新增 billing/crypto/wallet crate 及完整数据层

- 新增 aether-billing、aether-crypto、aether-wallet 独立 crate
- aether-data 扩展 repository 层:announcements、auth_modules、billing、
  candidate_selection、gemini_file_mappings、global_models、management_tokens、
  oauth_providers、proxy_nodes、quota、users、wallet 等模块
- aether-gateway 新增 api/auth/billing/control/middleware/scheduler/usage/
  video_tasks/hooks/maintenance/model_fetch/provider_transport 等功能模块
- 重构 executor decision 和 gateway state 为模块目录结构
- 新增 gateway router、frontdoor 路由层及对应测试
- Python 侧 API 路由重构,新增 compat/support 模块
- 前端 Logo 组件更新及 Provider 管理页面调整
This commit is contained in:
fawney19
2026-03-31 19:19:04 +08:00
parent b5a0070023
commit ddf18fed9a
690 changed files with 235087 additions and 16301 deletions

View File

@@ -0,0 +1,123 @@
from __future__ import annotations
from typing import Any
from unittest.mock import MagicMock
import pytest
from fastapi import FastAPI
from fastapi.testclient import TestClient
from src.database import get_db
def _build_app(monkeypatch: pytest.MonkeyPatch, *, pipeline_result: Any) -> tuple[TestClient, list[dict[str, Any]]]:
from src.api.public import videos as mod
app = FastAPI()
app.include_router(mod.router)
app.dependency_overrides[get_db] = lambda: MagicMock()
calls: list[dict[str, Any]] = []
async def _fake_pipeline_run(
*,
adapter: Any,
http_request: object,
db: object,
mode: object,
api_format_hint: str,
path_params: dict[str, Any] | None = None,
) -> Any:
del http_request, db
calls.append(
{
"adapter_type": type(adapter).__name__,
"mode": getattr(mode, "value", mode),
"api_format_hint": api_format_hint,
"path_params": path_params,
}
)
return pipeline_result
monkeypatch.setattr(mod.pipeline, "run", _fake_pipeline_run)
return TestClient(app), calls
def test_openai_video_create_route_is_pipeline_shell(monkeypatch: pytest.MonkeyPatch) -> None:
client, calls = _build_app(monkeypatch, pipeline_result={"ok": True})
response = client.post("/v1/videos", json={"model": "sora", "prompt": "hello"})
assert response.status_code == 200
assert response.json() == {"ok": True}
assert calls == [
{
"adapter_type": "OpenAIVideoAdapter",
"mode": "standard",
"api_format_hint": "openai:video",
"path_params": None,
}
]
def test_openai_video_download_route_passes_task_id_to_pipeline(
monkeypatch: pytest.MonkeyPatch,
) -> None:
client, calls = _build_app(monkeypatch, pipeline_result={"download": True})
response = client.get("/v1/videos/task-123/content")
assert response.status_code == 200
assert response.json() == {"download": True}
assert calls == [
{
"adapter_type": "OpenAIVideoAdapter",
"mode": "standard",
"api_format_hint": "openai:video",
"path_params": {"task_id": "task-123"},
}
]
def test_gemini_video_create_route_passes_model_to_pipeline(
monkeypatch: pytest.MonkeyPatch,
) -> None:
client, calls = _build_app(monkeypatch, pipeline_result={"ok": True})
response = client.post(
"/v1beta/models/veo-3:predictLongRunning",
json={"prompt": "hello"},
)
assert response.status_code == 200
assert response.json() == {"ok": True}
assert calls == [
{
"adapter_type": "GeminiVeoAdapter",
"mode": "standard",
"api_format_hint": "gemini:video",
"path_params": {"model": "veo-3"},
}
]
def test_gemini_video_cancel_route_reconstructs_operation_name(
monkeypatch: pytest.MonkeyPatch,
) -> None:
client, calls = _build_app(monkeypatch, pipeline_result={"ok": True})
response = client.post("/v1beta/models/veo-3/operations/op-1:cancel")
assert response.status_code == 200
assert response.json() == {"ok": True}
assert calls == [
{
"adapter_type": "GeminiVeoAdapter",
"mode": "standard",
"api_format_hint": "gemini:video",
"path_params": {
"task_id": "models/veo-3/operations/op-1",
"action": "cancel",
},
}
]