From 589110961a270733e4e3fb6add75117be124d984 Mon Sep 17 00:00:00 2001
From: Aarni Koskela <akx@iki.fi>
Date: Wed, 5 Mar 2025 14:02:19 +0200
Subject: [PATCH] Isolate redis-entraid dependency for tests (#3521)

Index: tests/test_asyncio/test_credentials.py
--- tests/test_asyncio/test_credentials.py.orig
+++ tests/test_asyncio/test_credentials.py
@@ -17,11 +17,15 @@ from redis.backoff import NoBackoff
 from redis.credentials import CredentialProvider, UsernamePasswordCredentialProvider
 from redis.exceptions import ConnectionError
 from redis.utils import str_if_bytes
-from redis_entraid.cred_provider import EntraIdCredentialsProvider
 from tests.conftest import get_endpoint, skip_if_redis_enterprise
 from tests.test_asyncio.conftest import get_credential_provider
 
+try:
+    from redis_entraid.cred_provider import EntraIdCredentialsProvider
+except ImportError:
+    EntraIdCredentialsProvider = None
 
+
 @pytest.fixture()
 def endpoint(request):
     endpoint_name = request.config.getoption("--endpoint-name")
@@ -321,6 +325,7 @@ class TestUsernamePasswordCredentialProvider:
 
 @pytest.mark.asyncio
 @pytest.mark.onlynoncluster
+@pytest.mark.skipif(not EntraIdCredentialsProvider, reason="requires redis-entraid")
 class TestStreamingCredentialProvider:
     @pytest.mark.parametrize(
         "credential_provider",
@@ -599,6 +604,7 @@ class TestStreamingCredentialProvider:
 @pytest.mark.asyncio
 @pytest.mark.onlynoncluster
 @pytest.mark.cp_integration
+@pytest.mark.skipif(not EntraIdCredentialsProvider, reason="requires redis-entraid")
 class TestEntraIdCredentialsProvider:
     @pytest.mark.parametrize(
         "r_credential",
@@ -674,6 +680,7 @@ class TestEntraIdCredentialsProvider:
 @pytest.mark.asyncio
 @pytest.mark.onlycluster
 @pytest.mark.cp_integration
+@pytest.mark.skipif(not EntraIdCredentialsProvider, reason="requires redis-entraid")
 class TestClusterEntraIdCredentialsProvider:
     @pytest.mark.parametrize(
         "r_credential",
