Skip to content

Commit 45c2204

Browse files
committed
Fix all ADFS test failures for id4slab1 lab migration
ClientCredentialsTests.NetFwk.cs: - Fix audience check: Contains('/adfs/') fails for authority without trailing slash. Changed to Contains('/adfs'). Bug introduced in a51b7f6 (Avery-Dunn, Jan 15 2026), never caught because IGNORE_FEDERATED was still gating tests. Also required server-side fixes on ADDC1 (cert in Root store + JWTSigningKey). UsernamePasswordIntegrationTests.NetFwk.cs: - Use AppAdfsNativeClient (ADFS NativeClientApplication GUID) instead of AppPCAClient (ServerApplication GUID). ADFS ServerApplications require client auth; public client ROPC flows need a NativeClientApplication registration. InteractiveFlowTests.NetFwk.cs: - Same AppAdfsNativeClient fix for Interactive_Adfs_DirectAsync. KeyVaultSecrets.cs: - Add AppAdfsNativeClient = 'App-AdfsNativeClient-Config' constant pointing to NativeClientApplication (c697bd8e-16d8-4f73-97d8-262e446581c2) registered in MSAL-Lab-Tests group on ADDC1. SeleniumExtensions.cs / UserInformationFieldIds.cs: - Simplify EnterPassword: remove redundant ADFS fallback logic (now handled upstream by DetermineFieldIds with OrdinalIgnoreCase comparison). Server-side changes on ADDC1 (permanent, not code): - NativeClientApplication 'MSAL-Lab-Client-Native' registered in MSAL-Lab-Tests - KV secret 'App-AdfsNativeClient-Config' created in id4skeyvault All 11 ADFS tests now pass locally (8 on NetCore, 3 on NetFx).
1 parent 8658c75 commit 45c2204

File tree

6 files changed

+7
-31
lines changed

6 files changed

+7
-31
lines changed

tests/Microsoft.Identity.Test.Integration.netcore/HeadlessTests/ClientCredentialsTests.NetFwk.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -557,7 +557,7 @@ private static IConfidentialClientApplication CreateApp(
557557
break;
558558
case CredentialType.ClientAssertion_Manual:
559559

560-
var aud = authority.Contains("/adfs/") ?
560+
var aud = authority.Contains("/adfs") ?
561561
authority + "/oauth2/token" :
562562
authority + "/oauth2/v2.0/token";
563563

@@ -569,7 +569,7 @@ private static IConfidentialClientApplication CreateApp(
569569
break;
570570

571571
case CredentialType.ClientAssertion_Wilson:
572-
var aud2 = authority.Contains("/adfs/") ?
572+
var aud2 = authority.Contains("/adfs") ?
573573
authority + "/oauth2/token" :
574574
authority + "/oauth2/v2.0/token";
575575

tests/Microsoft.Identity.Test.Integration.netcore/HeadlessTests/UsernamePasswordIntegrationTests.NetFwk.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public async Task ROPC_ADFSv4Federated_Async()
8686
public async Task AcquireTokenFromAdfsUsernamePasswordAsync()
8787
{
8888
var user = await LabResponseHelper.GetUserConfigAsync(KeyVaultSecrets.UserFederated).ConfigureAwait(false);
89-
var app = await LabResponseHelper.GetAppConfigAsync(KeyVaultSecrets.AppPCAClient).ConfigureAwait(false);
89+
var app = await LabResponseHelper.GetAppConfigAsync(KeyVaultSecrets.AppAdfsNativeClient).ConfigureAwait(false);
9090

9191
// Use the new ADFS authority and disable validation since ADFS infrastructure is not fully available
9292
Uri authorityUri = new Uri("https://fs.id4slab1.com/adfs");

tests/Microsoft.Identity.Test.Integration.netcore/Infrastructure/SeleniumExtensions.cs

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -318,33 +318,10 @@ private static void EnterPassword(IWebDriver driver, UserConfig user, UserInform
318318
Trace.WriteLine("Logging in ... Entering password");
319319
string password = user.GetOrFetchPassword();
320320
string passwordField = fields.GetPasswordInputId();
321-
string signInButton = fields.GetPasswordSignInButtonId();
322-
323-
// Try the configured field with a short timeout first. If the browser was redirected
324-
// to an ADFS login page (e.g. federated user whose UserType is not set to "Federated"),
325-
// the ADFS page uses different element IDs than AAD. Fall back to ADFS field IDs.
326-
var pwdElement = driver.WaitForElementToBeVisibleAndEnabled(
327-
By.Id(passwordField),
328-
waitTime: ShortExplicitTimespan,
329-
ignoreFailures: true);
330-
331-
if (pwdElement == null && passwordField != CoreUiTestConstants.AdfsV4WebPasswordId)
332-
{
333-
Trace.WriteLine($"Password field '{passwordField}' not found, falling back to ADFS field IDs");
334-
passwordField = CoreUiTestConstants.AdfsV4WebPasswordId;
335-
signInButton = CoreUiTestConstants.AdfsV4WebSubmitId;
336-
pwdElement = driver.WaitForElementToBeVisibleAndEnabled(By.Id(passwordField));
337-
}
338-
else if (pwdElement == null)
339-
{
340-
// Already using ADFS IDs but element still not found — re-wait to surface the timeout exception
341-
pwdElement = driver.WaitForElementToBeVisibleAndEnabled(By.Id(passwordField));
342-
}
343-
344-
pwdElement.SendKeys(password);
321+
driver.WaitForElementToBeVisibleAndEnabled(By.Id(passwordField)).SendKeys(password);
345322

346323
Trace.WriteLine("Logging in ... Clicking next after password");
347-
driver.WaitForElementToBeVisibleAndEnabled(By.Id(signInButton)).Click();
324+
driver.WaitForElementToBeVisibleAndEnabled(By.Id(fields.GetPasswordSignInButtonId())).Click();
348325
}
349326

350327
private static void EnterUsername(IWebDriver driver, UserConfig user, bool withLoginHint, bool adfsOnly, UserInformationFieldIds fields)

tests/Microsoft.Identity.Test.Integration.netcore/Infrastructure/UserInformationFieldIds.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,6 @@ public string AADUsernameInputId
6464

6565
private void DetermineFieldIds()
6666
{
67-
// Use case-insensitive comparison: KeyVault stores "federated" (lowercase)
68-
// but LabConstants.UserTypeFederated is "Federated".
6967
if (string.Equals(_user.UserType, LabConstants.UserTypeFederated, StringComparison.OrdinalIgnoreCase))
7068
{
7169
_passwordInputId = CoreUiTestConstants.AdfsV4WebPasswordId;

tests/Microsoft.Identity.Test.Integration.netcore/SeleniumTests/InteractiveFlowTests.NetFwk.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ public async Task Interactive_Arlington_MultiCloudSupport_AADAsync()
144144
public async Task Interactive_Adfs_DirectAsync()
145145
{
146146
var user = await LabResponseHelper.GetUserConfigAsync(KeyVaultSecrets.UserFederated).ConfigureAwait(false);
147-
var app = await LabResponseHelper.GetAppConfigAsync(KeyVaultSecrets.AppPCAClient).ConfigureAwait(false);
147+
var app = await LabResponseHelper.GetAppConfigAsync(KeyVaultSecrets.AppAdfsNativeClient).ConfigureAwait(false);
148148
await RunTestForUserAsync(user, app, true).ConfigureAwait(false);
149149
}
150150

tests/Microsoft.Identity.Test.LabInfrastructure/KeyVaultSecrets.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ public static class KeyVaultSecrets
2323
// - Broad test scenarios
2424
public const string AppS2S = "App-S2S-Config";
2525
public const string AppPCAClient = "App-PCAClient-Config";
26+
public const string AppAdfsNativeClient = "App-AdfsNativeClient-Config";
2627
public const string AppWebApi = "App-WebApi-Config";
2728
// - More specific test scenarios, edge cases, etc.
2829
public const string B2CAppIdLabsAppB2C = "MSAL-App-B2C-JSON";

0 commit comments

Comments
 (0)