Skip to content

Commit

Permalink
Workaround for async cred for browser auth
Browse files Browse the repository at this point in the history
  • Loading branch information
AsafMah committed Nov 21, 2023
1 parent 20ae9cc commit 4d04bd2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
11 changes: 5 additions & 6 deletions azure-kusto-data/tests/test_e2e_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,11 @@

import pytest
from azure.identity import DefaultAzureCredential

from azure.kusto.data.env_utils import get_env, get_app_id, get_auth_id, get_app_key, set_env, prepare_app_key_auth
from azure.kusto.data import KustoClient, KustoConnectionStringBuilder
from azure.kusto.data._cloud_settings import CloudSettings, DEFAULT_DEV_KUSTO_SERVICE_RESOURCE_ID
from azure.kusto.data._models import WellKnownDataSet
from azure.kusto.data._token_providers import AsyncDefaultAzureCredential
from azure.kusto.data.aio import KustoClient as AsyncKustoClient
from azure.kusto.data.env_utils import get_env, set_env, prepare_app_key_auth
from azure.kusto.data.exceptions import KustoServiceError
from azure.kusto.data.kusto_trusted_endpoints import MatchRule, well_known_kusto_endpoints
from azure.kusto.data.streaming_response import FrameType
Expand All @@ -43,7 +41,7 @@ class TestE2E:
test_db: ClassVar[Optional[str]]
ai_test_db: ClassVar[Optional[str]]
cred: ClassVar[DefaultAzureCredential]
async_cred: ClassVar[AsyncDefaultAzureCredential]
async_cred: ClassVar[DefaultAzureCredential]

CHUNK_SIZE = 1024

Expand Down Expand Up @@ -112,15 +110,16 @@ def setup_class(cls):
cls.ai_engine_cs = get_env("APPLICATION_INSIGHTS_ENGINE_CONNECTION_STRING", optional=True)

# Called to set the env variables for the default azure credentials
prepare_app_key_auth(optional=True)
print(prepare_app_key_auth(optional=True))

set_env("AZURE_AUTHORITY_HOST", "login.microsoftonline.com")

cls.test_db = get_env("TEST_DATABASE")
cls.ai_test_db = get_env("APPLICATION_INSIGHTS_TEST_DATABASE", optional=True) # name of e2e database could be changed

cls.cred = DefaultAzureCredential(exclude_interactive_browser_credential=False)
cls.async_cred = AsyncDefaultAzureCredential(exclude_interactive_browser_credential=False)
# Async credentials don't support interactive browser authentication for now, so until they do, we'll use the sync default credential for async tests
cls.async_cred = cls.cred

cls.input_folder_path = cls.get_file_path()

Expand Down
6 changes: 3 additions & 3 deletions azure-kusto-ingest/tests/test_e2e_ingest.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

from azure.kusto.data.env_utils import get_env, prepare_app_key_auth
from azure.kusto.data import KustoClient, KustoConnectionStringBuilder
from azure.kusto.data._token_providers import AsyncDefaultAzureCredential
from azure.kusto.data.aio import KustoClient as AsyncKustoClient
from azure.kusto.data.data_format import DataFormat, IngestionMappingKind
from azure.kusto.data.exceptions import KustoServiceError
Expand Down Expand Up @@ -60,7 +59,7 @@ class TestE2E:
json_file_path: ClassVar[str]
zipped_json_file_path: ClassVar[str]
cred: ClassVar[DefaultAzureCredential]
async_cred: ClassVar[AsyncDefaultAzureCredential]
async_cred: ClassVar[DefaultAzureCredential]

CHUNK_SIZE = 1024

Expand Down Expand Up @@ -173,7 +172,8 @@ def setup_class(cls):
cls.test_blob = get_env("TEST_BLOB", optional=True)

cls.cred = DefaultAzureCredential(exclude_interactive_browser_credential=False)
cls.async_cred = AsyncDefaultAzureCredential(exclude_interactive_browser_credential=False)
# Async credentials don't support interactive browser authentication for now, so until they do, we'll use the sync default credential for async tests
cls.async_cred = cls.cred

# Init clients
python_version = "_".join([str(v) for v in sys.version_info[:3]])
Expand Down

0 comments on commit 4d04bd2

Please sign in to comment.