@@ -44,9 +44,10 @@ def _get_token_from_cache_impl(self) -> Optional[dict]:
4444 return None
4545
4646
47- class TokenProviderTests ( unittest . TestCase ):
48- KUSTO_URI = get_env ( "ENGINE_CONNECTION_STRING" , optional = True )
47+ KUSTO_URI = get_env ( "ENGINE_CONNECTION_STRING" , None )
48+
4949
50+ class TokenProviderTests (unittest .TestCase ):
5051 @staticmethod
5152 def test_base_provider ():
5253 # test init with no URI
@@ -172,7 +173,7 @@ def test_az_provider():
172173 return
173174
174175 print ("Note!\n The test 'test_az_provider' will fail if 'az login' was not called." )
175- with AzCliTokenProvider (self . KUSTO_URI ) as provider :
176+ with AzCliTokenProvider (KUSTO_URI ) as provider :
176177 token = provider .get_token ()
177178 assert TokenProviderTests .get_token_value (token ) is not None
178179
@@ -190,21 +191,21 @@ def test_msi_provider():
190191 user_msi_client_id = get_env ("MSI_CLIENT_ID" , optional = True )
191192
192193 # system MSI
193- with MsiTokenProvider (self . KUSTO_URI ) as provider :
194+ with MsiTokenProvider (KUSTO_URI ) as provider :
194195 token = provider .get_token ()
195196 assert TokenProviderTests .get_token_value (token ) is not None
196197
197198 if user_msi_object_id is not None :
198199 args = {"object_id" : user_msi_object_id }
199- with MsiTokenProvider (self . KUSTO_URI , args ) as provider :
200+ with MsiTokenProvider (KUSTO_URI , args ) as provider :
200201 token = provider .get_token ()
201202 assert TokenProviderTests .get_token_value (token ) is not None
202203 else :
203204 print (" *** Skipped MSI Provider Client Id Test ***" )
204205
205206 if user_msi_client_id is not None :
206207 args = {"client_id" : user_msi_client_id }
207- with MsiTokenProvider (self . KUSTO_URI , args ) as provider :
208+ with MsiTokenProvider (KUSTO_URI , args ) as provider :
208209 token = provider .get_token ()
209210 assert TokenProviderTests .get_token_value (token ) is not None
210211 else :
@@ -217,7 +218,7 @@ def test_user_pass_provider():
217218 auth = get_env ("USER_AUTH_ID" , default = "organizations" )
218219
219220 if username and password and auth :
220- with UserPassTokenProvider (self . KUSTO_URI , auth , username , password ) as provider :
221+ with UserPassTokenProvider (KUSTO_URI , auth , username , password ) as provider :
221222 token = provider .get_token ()
222223 assert TokenProviderTests .get_token_value (token ) is not None
223224
@@ -237,7 +238,7 @@ def callback(x, x2, x3):
237238 # break here if you debug this test, and get the code from 'x'
238239 print (f"Please go to { x } and enter code { x2 } to authenticate, expires in { x3 } " )
239240
240- with DeviceLoginTokenProvider (self . KUSTO_URI , "organizations" , callback ) as provider :
241+ with DeviceLoginTokenProvider (KUSTO_URI , "organizations" , callback ) as provider :
241242 token = provider .get_token ()
242243 assert TokenProviderTests .get_token_value (token ) is not None
243244
@@ -252,7 +253,7 @@ def test_interactive_login():
252253 return
253254
254255 auth_id = get_auth_id ()
255- with InteractiveLoginTokenProvider (self . KUSTO_URI , auth_id ) as provider :
256+ with InteractiveLoginTokenProvider (KUSTO_URI , auth_id ) as provider :
256257 token = provider .get_token ()
257258 assert TokenProviderTests .get_token_value (token ) is not None
258259
@@ -269,7 +270,7 @@ def test_app_key_provider():
269270 app_key = get_app_key ()
270271
271272 if app_id and app_key and auth_id :
272- with ApplicationKeyTokenProvider (self . KUSTO_URI , auth_id , app_id , app_key ) as provider :
273+ with ApplicationKeyTokenProvider (KUSTO_URI , auth_id , app_id , app_key ) as provider :
273274 token = provider .get_token ()
274275 assert TokenProviderTests .get_token_value (token ) is not None
275276 else :
@@ -287,15 +288,15 @@ def test_app_cert_provider():
287288 with open (pem_key_path , "rb" ) as file :
288289 pem_key = file .read ()
289290
290- with ApplicationCertificateTokenProvider (self . KUSTO_URI , cert_app_id , cert_auth , pem_key , thumbprint ) as provider :
291+ with ApplicationCertificateTokenProvider (KUSTO_URI , cert_app_id , cert_auth , pem_key , thumbprint ) as provider :
291292 token = provider .get_token ()
292293 assert TokenProviderTests .get_token_value (token ) is not None
293294
294295 if public_cert_path :
295296 with open (public_cert_path , "r" ) as file :
296297 public_cert = file .read ()
297298
298- with ApplicationCertificateTokenProvider (self . KUSTO_URI , cert_app_id , cert_auth , pem_key , thumbprint , public_cert ) as provider :
299+ with ApplicationCertificateTokenProvider (KUSTO_URI , cert_app_id , cert_auth , pem_key , thumbprint , public_cert ) as provider :
299300 token = provider .get_token ()
300301 assert TokenProviderTests .get_token_value (token ) is not None
301302 else :
@@ -352,12 +353,12 @@ def test_azure_identity_default_token_provider():
352353 auth_id = get_auth_id ()
353354 app_key = get_app_key ()
354355
355- with AzureIdentityTokenCredentialProvider (self . KUSTO_URI , credential = DefaultAzureCredential ()) as provider :
356+ with AzureIdentityTokenCredentialProvider (KUSTO_URI , credential = DefaultAzureCredential ()) as provider :
356357 token = provider .get_token ()
357358 assert TokenProviderTests .get_token_value (token ) is not None
358359
359360 with AzureIdentityTokenCredentialProvider (
360- self . KUSTO_URI ,
361+ KUSTO_URI ,
361362 credential_from_login_endpoint = lambda login_endpoint : ClientSecretCredential (
362363 authority = login_endpoint , client_id = app_id , client_secret = app_key , tenant_id = auth_id
363364 ),
0 commit comments