litellm-mirror/tests/litellm/llms/custom_httpx/test_http_handler.py
Krrish Dholakia 8e27b2026a fix(http_handler.py): support reading ssl security level from env var
Allows user to specify lower security settings
2025-03-17 15:48:31 -07:00

29 lines
871 B
Python

import io
import os
import pathlib
import ssl
import sys
from unittest.mock import MagicMock
import pytest
sys.path.insert(
0, os.path.abspath("../../../..")
) # Adds the parent directory to the system path
import litellm
from litellm.llms.custom_httpx.http_handler import AsyncHTTPHandler, HTTPHandler
@pytest.mark.asyncio
async def test_ssl_security_level(monkeypatch):
# Set environment variable for SSL security level
monkeypatch.setenv("SSL_SECURITY_LEVEL", "DEFAULT@SECLEVEL=1")
# Create async client with SSL verification disabled to isolate SSL context testing
client = AsyncHTTPHandler(ssl_verify=False)
# Get the SSL context from the client
ssl_context = client.client._transport._pool._ssl_context
# Verify that the SSL context exists and has the correct cipher string
assert isinstance(ssl_context, ssl.SSLContext)