b4fbd6fe9f
Deploy Site / deploy-vercel (push) Has been skipped
Deploy Site / deploy-docs (push) Has been skipped
Build Skills Index / build-index (push) Has been skipped
CI / Deny unrelated histories (push) Has been skipped
CI / Detect affected areas (push) Successful in 27m35s
CI / OSV scan (push) Failing after 4s
CI / Build&Test Docker image (push) Successful in 9s
CI / Supply-chain scan (push) Has been skipped
CI / Lint Docker scripts (push) Failing after 5m13s
CI / Check contributors (push) Failing after 12m8s
CI / Docs Site (push) Failing after 12m8s
CI / TypeScript (push) Failing after 12m8s
CI / Python lints (push) Failing after 12m9s
CI / Python tests (push) Failing after 12m9s
CI / Check uv.lock (push) Failing after 23m22s
CI / CI timing report (push) Has been cancelled
Build Skills Index / trigger-deploy (push) Has been cancelled
CI / All required checks pass (push) Has been cancelled
73 lines
2.3 KiB
Python
73 lines
2.3 KiB
Python
"""Tests for per-provider TLS settings in custom_providers config."""
|
|
|
|
from hermes_cli.config import (
|
|
apply_custom_provider_tls_to_client_kwargs,
|
|
get_custom_provider_tls_settings,
|
|
)
|
|
|
|
|
|
def test_get_custom_provider_tls_settings_matches_base_url():
|
|
providers = [
|
|
{
|
|
"name": "Ollama",
|
|
"base_url": "https://ollama.example.com/v1",
|
|
"ssl_ca_cert": "/etc/ssl/mkcert-root.pem",
|
|
}
|
|
]
|
|
tls = get_custom_provider_tls_settings(
|
|
"https://ollama.example.com/v1/",
|
|
custom_providers=providers,
|
|
)
|
|
assert tls == {"ssl_ca_cert": "/etc/ssl/mkcert-root.pem"}
|
|
|
|
|
|
def test_apply_custom_provider_tls_to_client_kwargs():
|
|
client_kwargs = {"api_key": "x", "base_url": "https://ollama.example.com/v1"}
|
|
providers = [
|
|
{
|
|
"name": "Ollama",
|
|
"base_url": "https://ollama.example.com/v1",
|
|
"ssl_ca_cert": "/etc/ssl/mkcert-root.pem",
|
|
"ssl_verify": True,
|
|
}
|
|
]
|
|
apply_custom_provider_tls_to_client_kwargs(
|
|
client_kwargs,
|
|
"https://ollama.example.com/v1",
|
|
custom_providers=providers,
|
|
)
|
|
assert client_kwargs["ssl_ca_cert"] == "/etc/ssl/mkcert-root.pem"
|
|
assert client_kwargs["ssl_verify"] is True
|
|
|
|
|
|
def test_get_custom_provider_tls_settings_matches_case_insensitively():
|
|
"""A config base_url with mixed case must still match a lowercased runtime base_url."""
|
|
providers = [
|
|
{
|
|
"name": "Ollama",
|
|
"base_url": "https://Ollama.Example.com/v1",
|
|
"ssl_ca_cert": "/etc/ssl/mkcert-root.pem",
|
|
}
|
|
]
|
|
tls = get_custom_provider_tls_settings(
|
|
"https://ollama.example.com/v1",
|
|
custom_providers=providers,
|
|
)
|
|
assert tls == {"ssl_ca_cert": "/etc/ssl/mkcert-root.pem"}
|
|
|
|
|
|
def test_get_custom_provider_tls_settings_no_substring_bypass():
|
|
"""A base_url that is only a prefix of an entry must NOT match."""
|
|
providers = [
|
|
{
|
|
"name": "Ollama",
|
|
"base_url": "https://ollama.example.com/v1",
|
|
"ssl_verify": False,
|
|
}
|
|
]
|
|
# A different host that shares a prefix must not pick up ssl_verify:false.
|
|
assert get_custom_provider_tls_settings(
|
|
"https://ollama.example.com.attacker.test/v1",
|
|
custom_providers=providers,
|
|
) == {}
|