Skip to content

Commit bf044c5

Browse files
committed
Clean up unused helper methods in LabUserHelper
- Remove GetLabUserDataAsync (only used by obsolete GetAdfsUserAsync) - Remove GetAdfsUserAsync (no external callers, replaced by GetDefaultAdfsUserAsync) - Remove GetHybridSpaAccontAsync (no external callers, test now uses GetDefaultUserWithMultiTenantAppAsync) - Remove s_userCache field and System.Collections.Concurrent import (no longer needed) - Update TODO comments to remove references to deleted methods - All active functionality preserved, ~45 lines of obsolete code removed
1 parent 6666d35 commit bf044c5

File tree

1 file changed

+3
-46
lines changed

1 file changed

+3
-46
lines changed

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

Lines changed: 3 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// Licensed under the MIT License.
33

44
using System;
5-
using System.Collections.Concurrent;
65
using System.Diagnostics;
76
using System.Threading.Tasks;
87
using Newtonsoft.Json;
@@ -13,8 +12,6 @@ namespace Microsoft.Identity.Test.LabInfrastructure
1312
public static class LabUserHelper
1413
{
1514
private static readonly LabServiceApi s_labService;
16-
private static readonly ConcurrentDictionary<UserQuery, LabResponse> s_userCache =
17-
new ConcurrentDictionary<UserQuery, LabResponse>();
1815

1916
public static KeyVaultSecretsProvider KeyVaultSecretsProviderMsal { get; }
2017
public static KeyVaultSecretsProvider KeyVaultSecretsProviderMsid { get; }
@@ -26,31 +23,11 @@ static LabUserHelper()
2623
s_labService = new LabServiceApi();
2724
}
2825

29-
public static async Task<LabResponse> GetLabUserDataAsync(UserQuery query)
30-
{
31-
if (s_userCache.ContainsKey(query))
32-
{
33-
var cachedResponse = s_userCache[query];
34-
Debug.WriteLine($"Lab cache hit: {cachedResponse.User?.Upn ?? "N/A"} | {cachedResponse.App?.AppId ?? "N/A"} | {cachedResponse.Lab?.TenantId ?? "N/A"}");
35-
return cachedResponse;
36-
}
37-
38-
var response = await s_labService.GetLabResponseFromApiAsync(query).ConfigureAwait(false);
39-
if (response == null)
40-
{
41-
Debug.WriteLine($"Lab API returned null for query: {query}");
42-
throw new LabUserNotFoundException(query, "Found no users for the given query.");
43-
}
4426

45-
Debug.WriteLine($"Lab API: {response.User?.Upn ?? "N/A"} | {response.App?.AppId ?? "N/A"} | {response.Lab?.TenantId ?? "N/A"} | {response.User?.AzureEnvironment.ToString() ?? "N/A"}");
46-
47-
s_userCache.TryAdd(query, response);
48-
return response;
49-
}
5027

5128
private static async Task<LabResponse> GetKVLabDataAsync(string secret)
5229
{
53-
// TODO: Implement caching similar to GetLabUserDataAsync to avoid repeated Key Vault calls
30+
// TODO: Implement caching to avoid repeated Key Vault calls
5431
try
5532
{
5633
var keyVaultSecret = await KeyVaultSecretsProviderMsal.GetSecretByNameAsync(secret).ConfigureAwait(false);
@@ -166,10 +143,7 @@ public static Task<LabResponse> GetDefaultAdfsUserAsync()
166143
return MergeKVLabDataAsync("MSAL-USER-FedDefault-JSON", "ID4SLAB1", "MSAL-App-Default-JSON");
167144
}
168145

169-
public static Task<LabResponse> GetHybridSpaAccontAsync()
170-
{
171-
return MergeKVLabDataAsync("MSAL-User-Default-JSON", "ID4SLAB1", "MSAL-App-Default-JSON");
172-
}
146+
173147

174148
public static Task<LabResponse> GetB2CLocalAccountAsync()
175149
{
@@ -194,28 +168,11 @@ public static Task<LabResponse> GetCIAMUserAsync()
194168
return MergeKVLabDataAsync("MSAL-User-CIAM-JSON", "MSIDLABCIAM6", "MSAL-App-CIAM-JSON");
195169
}
196170

197-
public static Task<LabResponse> GetAdfsUserAsync(FederationProvider federationProvider, bool federated = true)
198-
{
199-
var query = new UserQuery()
200-
{
201-
AzureEnvironment = LabInfrastructure.AzureEnvironment.azurecloud,
202-
FederationProvider = federationProvider,
203-
UserType = federated ? UserType.Federated : UserType.Cloud
204-
};
205171

206-
if (!federated && federationProvider != FederationProvider.ADFSv2019)
207-
{
208-
Debug.WriteLine($"Invalid ADFS config: {federationProvider} non-federated not supported");
209-
throw new InvalidOperationException("Test Setup Error: MSAL only supports ADFS2019 direct (non-federated) access. " +
210-
"Support for older versions of ADFS is exclusively via federation");
211-
}
212-
213-
return GetLabUserDataAsync(query);
214-
}
215172

216173
public static string FetchUserPassword(string userLabName)
217174
{
218-
// TODO: Implement caching similar to GetLabUserDataAsync to avoid repeated Key Vault calls
175+
// TODO: Implement caching to avoid repeated Key Vault calls
219176
if (string.IsNullOrWhiteSpace(userLabName))
220177
{
221178
Debug.WriteLine("Password fetch failed: empty lab name");

0 commit comments

Comments
 (0)