@@ -27,7 +27,7 @@ def _get_app_and_auth_code(
2727 app = msal .ConfidentialClientApplication (
2828 client_id ,
2929 client_credential = client_secret ,
30- authority = authority , http_client = MinimalHttpClient ())
30+ authority = authority , http_client = MinimalHttpClient (timeout = 2 ))
3131 else :
3232 app = msal .PublicClientApplication (
3333 client_id , authority = authority , http_client = MinimalHttpClient ())
@@ -292,7 +292,7 @@ def test_client_secret(self):
292292 self .config ["client_id" ],
293293 client_credential = self .config .get ("client_secret" ),
294294 authority = self .config .get ("authority" ),
295- http_client = MinimalHttpClient ())
295+ http_client = MinimalHttpClient (timeout = 2 ))
296296 scope = self .config .get ("scope" , [])
297297 result = self .app .acquire_token_for_client (scope )
298298 self .assertIn ('access_token' , result )
@@ -307,7 +307,7 @@ def test_client_certificate(self):
307307 self .app = msal .ConfidentialClientApplication (
308308 self .config ['client_id' ],
309309 {"private_key" : private_key , "thumbprint" : client_cert ["thumbprint" ]},
310- http_client = MinimalHttpClient ())
310+ http_client = MinimalHttpClient (timeout = 2 ))
311311 scope = self .config .get ("scope" , [])
312312 result = self .app .acquire_token_for_client (scope )
313313 self .assertIn ('access_token' , result )
@@ -330,7 +330,7 @@ def test_subject_name_issuer_authentication(self):
330330 "thumbprint" : self .config ["thumbprint" ],
331331 "public_certificate" : public_certificate ,
332332 },
333- http_client = MinimalHttpClient ())
333+ http_client = MinimalHttpClient (timeout = 2 ))
334334 scope = self .config .get ("scope" , [])
335335 result = self .app .acquire_token_for_client (scope )
336336 self .assertIn ('access_token' , result )
@@ -379,14 +379,17 @@ def get_lab_app(
379379 client_id ,
380380 client_credential = client_secret ,
381381 authority = authority ,
382- http_client = MinimalHttpClient (),
382+ http_client = MinimalHttpClient (timeout = 2 ),
383383 ** kwargs )
384384
385385def get_session (lab_app , scopes ): # BTW, this infrastructure tests the confidential client flow
386386 logger .info ("Creating session" )
387- lab_token = lab_app .acquire_token_for_client (scopes )
387+ result = lab_app .acquire_token_for_client (scopes )
388+ assert result .get ("access_token" ), \
389+ "Unable to obtain token for lab. Encountered {}: {}" .format (
390+ result .get ("error" ), result .get ("error_description" ))
388391 session = requests .Session ()
389- session .headers .update ({"Authorization" : "Bearer %s" % lab_token ["access_token" ]})
392+ session .headers .update ({"Authorization" : "Bearer %s" % result ["access_token" ]})
390393 session .hooks ["response" ].append (lambda r , * args , ** kwargs : r .raise_for_status ())
391394 return session
392395
@@ -525,7 +528,7 @@ def _test_acquire_token_obo(self, config_pca, config_cca):
525528 config_cca ["client_id" ],
526529 client_credential = config_cca ["client_secret" ],
527530 authority = config_cca ["authority" ],
528- http_client = MinimalHttpClient (),
531+ http_client = MinimalHttpClient (timeout = 2 ),
529532 # token_cache= ..., # Default token cache is all-tokens-store-in-memory.
530533 # That's fine if OBO app uses short-lived msal instance per session.
531534 # Otherwise, the OBO app need to implement a one-cache-per-user setup.
@@ -553,7 +556,7 @@ def _test_acquire_token_by_client_secret(
553556 assert client_id and client_secret and authority and scope
554557 app = msal .ConfidentialClientApplication (
555558 client_id , client_credential = client_secret , authority = authority ,
556- http_client = MinimalHttpClient ())
559+ http_client = MinimalHttpClient (timeout = 2 ))
557560 result = app .acquire_token_for_client (scope )
558561 self .assertIsNotNone (result .get ("access_token" ), "Got %s instead" % result )
559562
@@ -852,7 +855,7 @@ def test_acquire_token_silent_with_an_empty_cache_should_return_none(self):
852855 usertype = "cloud" , azureenvironment = self .environment , publicClient = "no" )
853856 app = msal .ConfidentialClientApplication (
854857 config ['client_id' ], authority = config ['authority' ],
855- http_client = MinimalHttpClient ())
858+ http_client = MinimalHttpClient (timeout = 2 ))
856859 result = app .acquire_token_silent (scopes = config ['scope' ], account = None )
857860 self .assertEqual (result , None )
858861 # Note: An alias in this region is no longer accepting HTTPS traffic.
0 commit comments