Skip to content

Commit cf23892

Browse files
committed
Adapting to a lab change introduced today
1 parent ddb94b2 commit cf23892

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

tests/test_e2e.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -480,12 +480,17 @@ def get_lab_app(
480480
http_client=MinimalHttpClient(timeout=timeout),
481481
**kwargs)
482482

483+
class LabTokenError(RuntimeError):
484+
pass
485+
483486
def get_session(lab_app, scopes): # BTW, this infrastructure tests the confidential client flow
484487
logger.info("Creating session")
485488
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+
))
489494
session = requests.Session()
490495
session.headers.update({"Authorization": "Bearer %s" % result["access_token"]})
491496
session.hooks["response"].append(lambda r, *args, **kwargs: r.raise_for_status())
@@ -502,7 +507,13 @@ class LabBasedTestCase(E2eTestCase):
502507
@classmethod
503508
def setUpClass(cls):
504509
# 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+
])
506517

507518
@classmethod
508519
def tearDownClass(cls):

0 commit comments

Comments
 (0)