Skip to content

Commit

Permalink
connection string no authentication option + (local) test
Browse files Browse the repository at this point in the history
  • Loading branch information
t-ronmoneta committed Nov 14, 2023
1 parent 4519043 commit 14d6d6d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
13 changes: 13 additions & 0 deletions azure-kusto-data/azure/kusto/data/kcsb.py
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,19 @@ def with_azure_token_credential(

return kcsb

@classmethod
def with_no_authentication(cls, connection_string: str) -> "KustoConnectionStringBuilder":
"""
Create a KustoConnectionStringBuilder that uses no authentication.
:param connection_string: Kusto's connection string should be of the format: http://<clusterName>.kusto.windows.net
"""
if not connection_string.startswith("http://"):
raise ValueError("Connection string must start with http://")
kcsb = cls(connection_string)
kcsb[kcsb.ValidKeywords.aad_federated_security] = False

return kcsb

@property
def data_source(self) -> Optional[str]:
"""The URI specifying the Kusto service endpoint.
Expand Down
10 changes: 10 additions & 0 deletions azure-kusto-data/tests/test_kusto_connection_string_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
import unittest
from uuid import uuid4

import pytest
from azure.kusto.data import KustoConnectionStringBuilder, KustoClient

local_emulator = False

class KustoConnectionStringBuilderTests(unittest.TestCase):
"""Tests class for KustoConnectionStringBuilder."""
Expand Down Expand Up @@ -326,6 +328,14 @@ async def async_token_provider():
finally:
assert exception_occurred

@pytest.mark.skipif(not local_emulator, reason="requires aio")
def test_no_authentication(self):
kscb = KustoConnectionStringBuilder.with_no_authentication("http://localhost:8080")
assert kscb.data_source == "http://localhost:8080"
assert kscb.aad_federated_security is False



def test_initial_catalog_default(self):
kcsb = KustoConnectionStringBuilder.with_az_cli_authentication("https://help.kusto.windows.net")
assert kcsb.data_source == "https://help.kusto.windows.net"
Expand Down

0 comments on commit 14d6d6d

Please sign in to comment.