feat(cloud): support Anthropic provider base URL
Tests / Test passed: 665

This commit is contained in:
2026-07-14 07:58:38 +08:00
parent 8b7e5a2800
commit 9250254dec
13 changed files with 124 additions and 39 deletions
@@ -40,6 +40,15 @@ def test_build_cloud_planner_client_uses_managed_anthropic_key() -> None:
assert client._api_key == "managed-api-key"
def test_build_cloud_planner_client_uses_anthropic_base_url() -> None:
client = build_cloud_planner_client(
_resolved_profile("anthropic", base_url="https://anthropic-proxy.example")
)
assert isinstance(client, AnthropicToolCallingClient)
assert client._base_url == "https://anthropic-proxy.example"
def test_build_cloud_planner_client_uses_openai_compatible_base_url() -> None:
client = build_cloud_planner_client(
_resolved_profile("openai-compatible", base_url="https://compat.example/v1")
@@ -136,6 +136,29 @@ def test_provider_profile_requires_admin_scope(monkeypatch) -> None:
)
def test_anthropic_profile_accepts_custom_base_url(monkeypatch) -> None:
from cryptography.fernet import Fernet
monkeypatch.setenv(
"CLOUD_LLM_PROVIDER_ENCRYPTION_KEY", Fernet.generate_key().decode()
)
app = create_app(config=CloudControlConfig(database_url="sqlite:///:memory:"))
with TestClient(app) as client:
_create_admin(client)
response = client.post(
"/v1/planner/providers",
headers=_csrf_headers(client),
json=_profile_payload(
name="Anthropic proxy",
provider_type="anthropic",
base_url="https://anthropic-proxy.example/",
),
)
assert response.status_code == 201, response.text
assert response.json()["base_url"] == "https://anthropic-proxy.example"
def test_profile_write_requires_encryption_key(monkeypatch) -> None:
monkeypatch.delenv("CLOUD_LLM_PROVIDER_ENCRYPTION_KEY", raising=False)
app = create_app(config=CloudControlConfig(database_url="sqlite:///:memory:"))