Skip to content

Commit 3995ad0

Browse files
committed
Switch to the future-proof ciamcud tenant
Old ciam2 test tenant is obsolete
1 parent e7e7669 commit 3995ad0

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

tests/test_e2e.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import json
1717
import time
1818
import unittest
19+
from urllib.parse import urlparse, parse_qs
1920
import sys
2021
try:
2122
from unittest.mock import patch, ANY
@@ -1005,7 +1006,10 @@ class CiamTestCase(LabBasedTestCase):
10051006
@classmethod
10061007
def setUpClass(cls):
10071008
super(CiamTestCase, cls).setUpClass()
1008-
cls.user = cls.get_lab_user(federationProvider="ciam")
1009+
cls.user = cls.get_lab_user(
1010+
#federationProvider="ciam", # This line would return ciam2 tenant
1011+
federationProvider="ciamcud", signinAudience="AzureAdMyOrg", # ciam6
1012+
)
10091013
# FYI: Only single- or multi-tenant CIAM app can have other-than-OIDC
10101014
# delegated permissions on Microsoft Graph.
10111015
cls.app_config = cls.get_lab_app_object(cls.user["client_id"])
@@ -1020,13 +1024,17 @@ def test_ciam_acquire_token_interactive(self):
10201024
)
10211025

10221026
def test_ciam_acquire_token_for_client(self):
1027+
raw_url = self.app_config["clientSecret"]
1028+
secret_url = urlparse(raw_url)
1029+
if secret_url.query: # Ciam2 era has a query param Secret=name
1030+
secret_name = parse_qs(secret_url.query)["Secret"][0]
1031+
else: # Ciam6 era has a URL path that ends with the secret name
1032+
secret_name = secret_url.path.split("/")[-1]
1033+
logger.info('Detected secret name "%s" from "%s"', secret_name, raw_url)
10231034
self._test_acquire_token_by_client_secret(
10241035
client_id=self.app_config["appId"],
1025-
client_secret=self.get_lab_user_secret(
1026-
self.app_config["clientSecret"].split("=")[-1]),
1036+
client_secret=self.get_lab_user_secret(secret_name),
10271037
authority=self.app_config["authority"],
1028-
#scope=["{}/.default".format(self.app_config["appId"])], # AADSTS500207: The account type can't be used for the resource you're trying to access.
1029-
#scope=["api://{}/.default".format(self.app_config["appId"])], # AADSTS500011: The resource principal named api://ced781e7-bdb0-4c99-855c-d3bacddea88a was not found in the tenant named MSIDLABCIAM2. This can happen if the application has not been installed by the administrator of the tenant or consented to by any user in the tenant. You might have sent your authentication request to the wrong tenant.
10301038
scope=self.app_config["scopes"], # It shall ends with "/.default"
10311039
)
10321040

@@ -1046,6 +1054,8 @@ def test_ciam_acquire_token_by_ropc(self):
10461054
scope=self.app_config["scopes"],
10471055
)
10481056

1057+
@unittest.skip("""As of Aug 2024, in both ciam2 and ciam6, sign-in fails with
1058+
AADSTS500208: The domain is not a valid login domain for the account type.""")
10491059
def test_ciam_device_flow(self):
10501060
self._test_device_flow(
10511061
authority=self.app_config["authority"],

0 commit comments

Comments
 (0)