@@ -27,7 +27,7 @@ def _get_app_and_auth_code(
27
27
app = msal .ConfidentialClientApplication (
28
28
client_id ,
29
29
client_credential = client_secret ,
30
- authority = authority , http_client = MinimalHttpClient ())
30
+ authority = authority , http_client = MinimalHttpClient (timeout = 2 ))
31
31
else :
32
32
app = msal .PublicClientApplication (
33
33
client_id , authority = authority , http_client = MinimalHttpClient ())
@@ -292,7 +292,7 @@ def test_client_secret(self):
292
292
self .config ["client_id" ],
293
293
client_credential = self .config .get ("client_secret" ),
294
294
authority = self .config .get ("authority" ),
295
- http_client = MinimalHttpClient ())
295
+ http_client = MinimalHttpClient (timeout = 2 ))
296
296
scope = self .config .get ("scope" , [])
297
297
result = self .app .acquire_token_for_client (scope )
298
298
self .assertIn ('access_token' , result )
@@ -307,7 +307,7 @@ def test_client_certificate(self):
307
307
self .app = msal .ConfidentialClientApplication (
308
308
self .config ['client_id' ],
309
309
{"private_key" : private_key , "thumbprint" : client_cert ["thumbprint" ]},
310
- http_client = MinimalHttpClient ())
310
+ http_client = MinimalHttpClient (timeout = 2 ))
311
311
scope = self .config .get ("scope" , [])
312
312
result = self .app .acquire_token_for_client (scope )
313
313
self .assertIn ('access_token' , result )
@@ -330,7 +330,7 @@ def test_subject_name_issuer_authentication(self):
330
330
"thumbprint" : self .config ["thumbprint" ],
331
331
"public_certificate" : public_certificate ,
332
332
},
333
- http_client = MinimalHttpClient ())
333
+ http_client = MinimalHttpClient (timeout = 2 ))
334
334
scope = self .config .get ("scope" , [])
335
335
result = self .app .acquire_token_for_client (scope )
336
336
self .assertIn ('access_token' , result )
@@ -379,14 +379,17 @@ def get_lab_app(
379
379
client_id ,
380
380
client_credential = client_secret ,
381
381
authority = authority ,
382
- http_client = MinimalHttpClient (),
382
+ http_client = MinimalHttpClient (timeout = 2 ),
383
383
** kwargs )
384
384
385
385
def get_session (lab_app , scopes ): # BTW, this infrastructure tests the confidential client flow
386
386
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" ))
388
391
session = requests .Session ()
389
- session .headers .update ({"Authorization" : "Bearer %s" % lab_token ["access_token" ]})
392
+ session .headers .update ({"Authorization" : "Bearer %s" % result ["access_token" ]})
390
393
session .hooks ["response" ].append (lambda r , * args , ** kwargs : r .raise_for_status ())
391
394
return session
392
395
@@ -525,7 +528,7 @@ def _test_acquire_token_obo(self, config_pca, config_cca):
525
528
config_cca ["client_id" ],
526
529
client_credential = config_cca ["client_secret" ],
527
530
authority = config_cca ["authority" ],
528
- http_client = MinimalHttpClient (),
531
+ http_client = MinimalHttpClient (timeout = 2 ),
529
532
# token_cache= ..., # Default token cache is all-tokens-store-in-memory.
530
533
# That's fine if OBO app uses short-lived msal instance per session.
531
534
# Otherwise, the OBO app need to implement a one-cache-per-user setup.
@@ -553,7 +556,7 @@ def _test_acquire_token_by_client_secret(
553
556
assert client_id and client_secret and authority and scope
554
557
app = msal .ConfidentialClientApplication (
555
558
client_id , client_credential = client_secret , authority = authority ,
556
- http_client = MinimalHttpClient ())
559
+ http_client = MinimalHttpClient (timeout = 2 ))
557
560
result = app .acquire_token_for_client (scope )
558
561
self .assertIsNotNone (result .get ("access_token" ), "Got %s instead" % result )
559
562
@@ -852,7 +855,7 @@ def test_acquire_token_silent_with_an_empty_cache_should_return_none(self):
852
855
usertype = "cloud" , azureenvironment = self .environment , publicClient = "no" )
853
856
app = msal .ConfidentialClientApplication (
854
857
config ['client_id' ], authority = config ['authority' ],
855
- http_client = MinimalHttpClient ())
858
+ http_client = MinimalHttpClient (timeout = 2 ))
856
859
result = app .acquire_token_silent (scopes = config ['scope' ], account = None )
857
860
self .assertEqual (result , None )
858
861
# Note: An alias in this region is no longer accepting HTTPS traffic.
0 commit comments