Skip to content

Commit 27b72c8

Browse files
authored
Removing hardcoded client_ids from test environment (#220)
1 parent 37edf48 commit 27b72c8

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

tests/test_e2e.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,6 @@ def test_ropc_adfs2019_onprem(self):
482482
# Configuration is derived from https://github.com/AzureAD/microsoft-authentication-library-for-dotnet/blob/4.7.0/tests/Microsoft.Identity.Test.Common/TestConstants.cs#L250-L259
483483
config = self.get_lab_user(usertype="onprem", federationProvider="ADFSv2019")
484484
config["authority"] = "https://fs.%s.com/adfs" % config["lab_name"]
485-
config["client_id"] = "PublicClientId"
486485
config["scope"] = self.adfs2019_scopes
487486
config["password"] = self.get_lab_user_secret(config["lab_name"])
488487
self._test_username_password(**config)
@@ -497,26 +496,31 @@ def test_adfs2019_onprem_acquire_token_by_auth_code(self):
497496
"""
498497
config = self.get_lab_user(usertype="onprem", federationProvider="ADFSv2019")
499498
config["authority"] = "https://fs.%s.com/adfs" % config["lab_name"]
500-
config["client_id"] = "PublicClientId"
501499
config["scope"] = self.adfs2019_scopes
502500
config["port"] = 8080
503501
self._test_acquire_token_by_auth_code(**config)
504502

505503
@unittest.skipUnless(
506504
os.getenv("LAB_OBO_CLIENT_SECRET"),
507505
"Need LAB_OBO_CLIENT SECRET from https://msidlabs.vault.azure.net/secrets/TodoListServiceV2-OBO/c58ba97c34ca4464886943a847d1db56")
506+
@unittest.skipUnless(
507+
os.getenv("LAB_OBO_CONFIDENTIAL_CLIENT_ID"),
508+
"Confidential client id can be found here https://docs.msidlab.com/flows/onbehalfofflow.html")
509+
@unittest.skipUnless(
510+
os.getenv("LAB_OBO_PUBLIC_CLIENT_ID"),
511+
"Public client id can be found here https://docs.msidlab.com/flows/onbehalfofflow.html")
508512
def test_acquire_token_obo(self):
509513
config = self.get_lab_user(usertype="cloud")
510514

511515
config_cca = {}
512516
config_cca.update(config)
513-
config_cca["client_id"] = "f4aa5217-e87c-42b2-82af-5624dd14ee72"
517+
config_cca["client_id"] = os.getenv("LAB_OBO_CONFIDENTIAL_CLIENT_ID")
514518
config_cca["scope"] = ["https://graph.microsoft.com/.default"]
515519
config_cca["client_secret"] = os.getenv("LAB_OBO_CLIENT_SECRET")
516520

517521
config_pca = {}
518522
config_pca.update(config)
519-
config_pca["client_id"] = "c0485386-1e9a-4663-bc96-7ab30656de7f"
523+
config_pca["client_id"] = os.getenv("LAB_OBO_PUBLIC_CLIENT_ID")
520524
config_pca["password"] = self.get_lab_user_secret(config_pca["lab_name"])
521525
config_pca["scope"] = ["api://%s/read" % config_cca["client_id"]]
522526

@@ -535,20 +539,22 @@ def test_b2c_acquire_token_by_auth_code(self):
535539
# This won't work https://msidlab.com/api/user?usertype=b2c
536540
password="***" # From https://aka.ms/GetLabUserSecret?Secret=msidlabb2c
537541
"""
542+
config = self.get_lab_app_object(azureenvironment="azureb2ccloud")
538543
self._test_acquire_token_by_auth_code(
539544
authority=self._build_b2c_authority("B2C_1_SignInPolicy"),
540-
client_id="b876a048-55a5-4fc5-9403-f5d90cb1c852",
545+
client_id=config["appId"],
541546
port=3843, # Lab defines 4 of them: [3843, 4584, 4843, 60000]
542-
scope=["https://msidlabb2c.onmicrosoft.com/msaapp/user_impersonation"]
547+
scope=config["defaultScopes"].split(','),
543548
)
544549

545550
def test_b2c_acquire_token_by_ropc(self):
551+
config = self.get_lab_app_object(azureenvironment="azureb2ccloud")
546552
self._test_username_password(
547553
authority=self._build_b2c_authority("B2C_1_ROPC_Auth"),
548-
client_id="e3b9ad76-9763-4827-b088-80c7a7888f79",
554+
client_id=config["appId"],
549555
username="[email protected]",
550556
password=self.get_lab_user_secret("msidlabb2c"),
551-
scope=["https://msidlabb2c.onmicrosoft.com/msidlabb2capi/read"],
557+
scope=config["defaultScopes"].split(','),
552558
)
553559

554560

0 commit comments

Comments
 (0)