Skip to content

Commit 2cfe180

Browse files
authored
users/asafsmahlev/minor_fixes (#533)
1 parent a436993 commit 2cfe180

File tree

8 files changed

+61
-5
lines changed

8 files changed

+61
-5
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
## [4.4.1] - 2024-05-06
8+
9+
### Fixed
10+
- Fixed bug in ManagedIdentity close method
11+
- Fixed bug in IngestionResult repr
12+
713
## [4.4.0] - 2024-04-08
814

915
### Added

azure-kusto-data/azure/kusto/data/_token_providers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ def _get_token_from_cache_impl(self) -> Optional[dict]:
401401
def close(self):
402402
if self._msi_auth_context is not None:
403403
self._msi_auth_context.close()
404-
if self._msi_auth_context is not None:
404+
if self._msi_auth_context_async is not None:
405405
raise KustoAsyncUsageError("Can't close async token provider with sync close", self.is_async)
406406

407407
async def close_async(self):
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# Copyright (c) Microsoft Corporation.
22
# Licensed under the MIT License
3-
VERSION = "4.4.0"
3+
VERSION = "4.4.1"

azure-kusto-data/tests/aio/test_async_token_providers.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,3 +354,22 @@ async def test_azure_identity_token_provider(self):
354354
) as provider:
355355
token = await provider.get_token_async()
356356
assert TokenProviderTests.get_token_value(token) is not None
357+
358+
@aio_documented_by(TokenProviderTests.test_sanity_close)
359+
@pytest.mark.asyncio
360+
async def test_sanity_close(self):
361+
DUMMY_URI = "https://dummy_uri.kusto.windows.net"
362+
providers = [
363+
MsiTokenProvider(DUMMY_URI, is_async=True),
364+
AzCliTokenProvider(DUMMY_URI, is_async=True),
365+
UserPassTokenProvider(DUMMY_URI, "organizations", "a", "b", is_async=True),
366+
ApplicationKeyTokenProvider(DUMMY_URI, "a", "b", "c", is_async=True),
367+
ApplicationCertificateTokenProvider(DUMMY_URI, "a", "b", "c", "d", is_async=True),
368+
CallbackTokenProvider(lambda: "a", None),
369+
AzureIdentityTokenCredentialProvider(DUMMY_URI, credential=AsyncDefaultAzureCredential(), is_async=True),
370+
DeviceLoginTokenProvider(DUMMY_URI, "organizations", lambda x, x2, x3: None, is_async=True),
371+
]
372+
373+
for provider in providers:
374+
async with provider:
375+
pass

azure-kusto-data/tests/test_token_providers.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,3 +370,21 @@ def test_azure_identity_default_token_provider():
370370
) as provider:
371371
token = provider.get_token()
372372
assert TokenProviderTests.get_token_value(token) is not None
373+
374+
@staticmethod
375+
def test_sanity_close():
376+
DUMMY_URI = "https://dummy_uri.kusto.windows.net"
377+
providers = [
378+
MsiTokenProvider(DUMMY_URI),
379+
AzCliTokenProvider(DUMMY_URI),
380+
UserPassTokenProvider(DUMMY_URI, "organizations", "a", "b"),
381+
ApplicationKeyTokenProvider(DUMMY_URI, "a", "b", "c"),
382+
ApplicationCertificateTokenProvider(DUMMY_URI, "a", "b", "c", "d"),
383+
CallbackTokenProvider(lambda: "a", None),
384+
AzureIdentityTokenCredentialProvider(DUMMY_URI, credential=DefaultAzureCredential()),
385+
DeviceLoginTokenProvider(DUMMY_URI, "organizations", lambda x, x2, x3: None),
386+
]
387+
388+
for provider in providers:
389+
with provider:
390+
pass
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# Copyright (c) Microsoft Corporation.
22
# Licensed under the MIT License
3-
VERSION = "4.4.0"
3+
VERSION = "4.4.1"

azure-kusto-ingest/azure/kusto/ingest/base_ingest_client.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,11 @@ def __init__(self, status: IngestionStatus, database: str, table: str, source_id
6565

6666
def __repr__(self):
6767
# Remove query parameters from blob_uri, if exists
68+
obfuscated_path = None
6869
if isinstance(self.blob_uri, str):
6970
obfuscated_path = self.blob_uri.split("?")[0].split(";")[0]
70-
return f"IngestionResult(status={self.status}, database={self.database}, table={self.table}, source_id={self.source_id}, blob_uri={obfuscated_path})"
71+
blob_uri = f", obfuscated_blob_uri={obfuscated_path}" if obfuscated_path else ""
72+
return f"IngestionResult(status={self.status}, database={self.database}, table={self.table}, source_id={self.source_id}{blob_uri})"
7173

7274

7375
class BaseIngestClient(metaclass=ABCMeta):

azure-kusto-ingest/tests/test_status_q.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@
33
import json
44
import time
55
import unittest
6+
import uuid
67
from unittest import mock
78
from uuid import uuid4
89

910
from azure.storage.queue import QueueMessage, QueueClient
1011

11-
from azure.kusto.ingest import QueuedIngestClient
12+
from azure.kusto.ingest import QueuedIngestClient, IngestionResult, IngestionStatus
1213
from azure.kusto.ingest._resource_manager import _ResourceUri
1314
from azure.kusto.ingest.status import KustoIngestStatusQueues, SuccessMessage, FailureMessage
1415

@@ -251,3 +252,13 @@ def test_pop_unbalanced_queues(self):
251252
actual[call_args[0][0].queue_name] = actual.get(call_args[0][0].queue_name, 0) + call_args[1]["messages_per_page"]
252253

253254
assert actual[fake_failed_queue2.object_name] + actual[fake_failed_queue1.object_name] == (4 + 4 + 6)
255+
256+
def test_status_sanity(self):
257+
i = IngestionResult(IngestionStatus.QUEUED, "db", "table", uuid.UUID("11111111-1111-1111-1111-111111111111"), "path")
258+
assert (
259+
repr(i)
260+
== "IngestionResult(status=IngestionStatus.QUEUED, database=db, table=table, source_id=11111111-1111-1111-1111-111111111111, obfuscated_blob_uri=path)"
261+
)
262+
263+
no_path = IngestionResult(IngestionStatus.QUEUED, "db", "table", uuid.UUID("11111111-1111-1111-1111-111111111111"))
264+
assert repr(no_path) == "IngestionResult(status=IngestionStatus.QUEUED, database=db, table=table, source_id=11111111-1111-1111-1111-111111111111)"

0 commit comments

Comments
 (0)