mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-19 00:01:29 +00:00
base URL trailing slashes
This commit is contained in:
parent
bc94878395
commit
5b608a27db
2 changed files with 20 additions and 0 deletions
|
|
@ -60,6 +60,7 @@ class CatoNetworksGuardrail(CustomGuardrail):
|
|||
or os.environ.get("CATO_API_BASE")
|
||||
or "https://api.aisec.catonetworks.com"
|
||||
)
|
||||
self.api_base = self.api_base.rstrip("/")
|
||||
self.ws_api_base = self.api_base.replace("http://", "ws://").replace(
|
||||
"https://", "wss://"
|
||||
)
|
||||
|
|
|
|||
|
|
@ -381,6 +381,25 @@ def test_init_http_api_base_maps_to_ws():
|
|||
assert guard.ws_api_base == "ws://insecure.example.com"
|
||||
|
||||
|
||||
@pytest.mark.parametrize("api_base", [
|
||||
"https://api.aisec.catonetworks.com/",
|
||||
"https://api.aisec.catonetworks.com",
|
||||
])
|
||||
def test_base_url_trailing_slash(monkeypatch, api_base):
|
||||
monkeypatch.setenv("CATO_API_KEY", "test-key")
|
||||
guardrail = CatoNetworksGuardrail(api_base=api_base)
|
||||
assert guardrail.api_base == "https://api.aisec.catonetworks.com"
|
||||
assert guardrail.ws_api_base == "wss://api.aisec.catonetworks.com"
|
||||
|
||||
|
||||
def test_base_url_from_env(monkeypatch):
|
||||
monkeypatch.setenv("CATO_API_KEY", "test-key")
|
||||
monkeypatch.setenv("CATO_API_BASE", "https://api.aisec.catonetworks.com/")
|
||||
guardrail = CatoNetworksGuardrail(api_base=None)
|
||||
assert guardrail.api_base == "https://api.aisec.catonetworks.com"
|
||||
assert guardrail.ws_api_base == "wss://api.aisec.catonetworks.com"
|
||||
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# _build_cato_headers direct coverage
|
||||
# -----------------------------------------------------------------------------
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue