This commit is contained in:
@@ -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:"))
|
||||
|
||||
Reference in New Issue
Block a user