mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-14 23:21:35 +00:00
test(redis): verify explicit Azure credential provider
Co-Authored-By: Ishaan Jaffer <155045088+ishaan-berri@users.noreply.github.com>
This commit is contained in:
parent
fb4d32efea
commit
9557fbd6c4
1 changed files with 11 additions and 17 deletions
|
|
@ -3008,13 +3008,10 @@ def test_generate_azure_ad_redis_token_import_error():
|
|||
|
||||
|
||||
def test_redis_client_logic_azure_ad_auth():
|
||||
"""Test that _get_redis_client_logic sets up Azure AD auth when REDIS_AZURE_AD_TOKEN=true.
|
||||
|
||||
Mocks ``azure.identity`` via ``sys.modules`` so the test does not require
|
||||
the real ``azure-identity`` package to be installed in the CI environment.
|
||||
"""
|
||||
from unittest.mock import Mock, patch
|
||||
|
||||
from litellm._redis_credential_provider import AzureADCredentialProvider
|
||||
|
||||
mock_credential = Mock()
|
||||
mock_azure_identity = Mock()
|
||||
mock_azure_identity.DefaultAzureCredential = Mock(return_value=mock_credential)
|
||||
|
|
@ -3024,7 +3021,10 @@ def test_redis_client_logic_azure_ad_auth():
|
|||
with patch.dict(
|
||||
"sys.modules", {"azure.identity": mock_azure_identity, "azure": Mock()}
|
||||
):
|
||||
from litellm._redis import _get_redis_client_logic
|
||||
from litellm._redis import (
|
||||
_REDIS_CREDENTIAL_PROVIDER_KEY,
|
||||
_get_redis_client_logic,
|
||||
)
|
||||
|
||||
redis_kwargs = _get_redis_client_logic(
|
||||
host="myredis.redis.cache.windows.net",
|
||||
|
|
@ -3034,17 +3034,11 @@ def test_redis_client_logic_azure_ad_auth():
|
|||
)
|
||||
|
||||
assert "redis_connect_func" in redis_kwargs
|
||||
# Marker for async paths to detect Azure AD auth
|
||||
assert hasattr(redis_kwargs["redis_connect_func"], "_azure_redis_ad_token")
|
||||
assert redis_kwargs["redis_connect_func"]._azure_redis_ad_token is True
|
||||
# Live credential object (not raw secret) is exposed for async paths
|
||||
assert hasattr(redis_kwargs["redis_connect_func"], "_azure_credential")
|
||||
# Raw credentials must NOT be exposed on the function
|
||||
assert not hasattr(redis_kwargs["redis_connect_func"], "_azure_client_secret")
|
||||
assert not hasattr(redis_kwargs["redis_connect_func"], "_azure_client_id")
|
||||
assert not hasattr(redis_kwargs["redis_connect_func"], "_azure_tenant_id")
|
||||
|
||||
# Azure-specific kwargs should be removed from the dict passed to Redis
|
||||
assert isinstance(
|
||||
redis_kwargs[_REDIS_CREDENTIAL_PROVIDER_KEY],
|
||||
AzureADCredentialProvider,
|
||||
)
|
||||
assert not hasattr(redis_kwargs["redis_connect_func"], "_azure_redis_ad_token")
|
||||
assert "azure_redis_ad_token" not in redis_kwargs
|
||||
assert "azure_client_id" not in redis_kwargs
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue