@@ -480,12 +480,17 @@ def get_lab_app(
480
480
http_client = MinimalHttpClient (timeout = timeout ),
481
481
** kwargs )
482
482
483
+ class LabTokenError (RuntimeError ):
484
+ pass
485
+
483
486
def get_session (lab_app , scopes ): # BTW, this infrastructure tests the confidential client flow
484
487
logger .info ("Creating session" )
485
488
result = lab_app .acquire_token_for_client (scopes )
486
- assert result .get ("access_token" ), \
487
- "Unable to obtain token for lab. Encountered {}: {}" .format (
488
- result .get ("error" ), result .get ("error_description" ))
489
+ if not result .get ("access_token" ):
490
+ raise LabTokenError (
491
+ "Unable to obtain token for lab. Encountered {}: {}" .format (
492
+ result .get ("error" ), result .get ("error_description" )
493
+ ))
489
494
session = requests .Session ()
490
495
session .headers .update ({"Authorization" : "Bearer %s" % result ["access_token" ]})
491
496
session .hooks ["response" ].append (lambda r , * args , ** kwargs : r .raise_for_status ())
@@ -502,7 +507,13 @@ class LabBasedTestCase(E2eTestCase):
502
507
@classmethod
503
508
def setUpClass (cls ):
504
509
# https://docs.msidlab.com/accounts/apiaccess.html#code-snippet
505
- cls .session = get_session (get_lab_app (), ["https://msidlab.com/.default" ])
510
+ try :
511
+ cls .session = get_session (get_lab_app (), ["https://msidlab.com/.default" ])
512
+ except LabTokenError :
513
+ cls .session = get_session (get_lab_app (), [
514
+ # A lab change since June 10, 2024 which may or may not be reverted
515
+ "https://request.msidlab.com/.default" ,
516
+ ])
506
517
507
518
@classmethod
508
519
def tearDownClass (cls ):
0 commit comments