Skip to content

Commit 81ec518

Browse files
committed
Simplify the lab api
1 parent 965e3ed commit 81ec518

File tree

10 files changed

+6
-198
lines changed

10 files changed

+6
-198
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public static X509Certificate2 FindCertificateByName(string subjectName)
3636
/// <param subjectName="location"><see cref="StoreLocation"/> in which to search for a matching certificate</param>
3737
/// <param subjectName="name"><see cref="StoreName"/> in which to search for a matching certificate</param>
3838
/// <returns><see cref="X509Certificate2"/> with <paramref subjectName="certName"/>, or null if no matching certificate was found</returns>
39-
public static X509Certificate2 FindCertificateByName(string certName, StoreLocation location, StoreName name)
39+
private static X509Certificate2 FindCertificateByName(string certName, StoreLocation location, StoreName name)
4040
{
4141
// Unix LocalMachine X509Store is limited to the Root and CertificateAuthority stores
4242
if (SharedUtilities.IsLinuxPlatform())

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

Lines changed: 0 additions & 38 deletions
This file was deleted.

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

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -29,33 +29,7 @@ public class KeyVaultSecretsProvider : IDisposable
2929
private CertificateClient _certificateClient;
3030
private SecretClient _secretClient;
3131

32-
/// <summary>Initialize the secrets provider with the "keyVault" configuration section.</summary>
33-
/// <remarks>
34-
/// <para>
35-
/// Authentication using <see cref="LabAccessAuthenticationType.ClientCertificate"/>
36-
/// 1. Register Azure AD application of "Web app / API" type.
37-
/// To set up certificate based access to the application PowerShell should be used.
38-
/// 2. Add an access policy entry to target Key Vault instance for this application.
39-
///
40-
/// The "keyVault" configuration section should define:
41-
/// "authType": "ClientCertificate"
42-
/// "clientId": [client ID]
43-
/// "certThumbprint": [certificate thumbprint]
44-
/// </para>
45-
/// <para>
46-
/// Authentication using <see cref="LabAccessAuthenticationType.UserCredential"/>
47-
/// 1. Register Azure AD application of "Native" type.
48-
/// 2. Add to 'Required permissions' access to 'Azure Key Vault (AzureKeyVault)' API.
49-
/// 3. When you run your native client application, it will automatically prompt user to enter Azure AD credentials.
50-
/// 4. To successfully access keys/secrets in the Key Vault, the user must have specific permissions to perform those operations.
51-
/// This could be achieved by directly adding an access policy entry to target Key Vault instance for this user
52-
/// or an access policy entry for an Azure AD security group of which this user is a member of.
53-
///
54-
/// The "keyVault" configuration section should define:
55-
/// "authType": "UserCredential"
56-
/// "clientId": [client ID]
57-
/// </para>
58-
/// </remarks>
32+
5933
public KeyVaultSecretsProvider(string keyVaultAddress = KeyVaultInstance.MSIDLab)
6034
{
6135
var credentials = GetKeyVaultCredentialAsync().GetAwaiter().GetResult();

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

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,4 @@ public static async Task<AccessToken> GetLabAccessTokenAsync(string authority, s
7070
}
7171
}
7272

73-
public enum LabAccessAuthenticationType
74-
{
75-
ClientCertificate,
76-
ClientSecret,
77-
UserCredential
78-
}
7973
}

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

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,12 @@ public class LabApp
2626
[JsonProperty("redirecturi")]
2727
public string RedirectUri { get; set; }
2828

29-
[JsonProperty("signinaudience")]
30-
public string Audience { get; set; }
31-
3229
// TODO: this is a list, but lab sends a string. Not used today, discuss with lab to return a list
3330
[JsonProperty("authority")]
3431
public string Authority { get; set; }
3532

3633
[JsonProperty("defaultscopes")]
3734
public string DefaultScopes { get; set; }
38-
3935
}
4036

4137
public class Lab
@@ -46,16 +42,7 @@ public class Lab
4642
[JsonProperty("federationprovider")]
4743
public FederationProvider FederationProvider { get; set; }
4844

49-
[JsonProperty("credentialvaultkeyname")]
50-
public string CredentialVaultkeyName { get; set; }
51-
5245
[JsonProperty("authority")]
5346
public string Authority { get; set; }
5447
}
55-
56-
public class LabCredentialResponse
57-
{
58-
[JsonProperty("Value")]
59-
public string Secret { get; set; }
60-
}
6148
}

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

Lines changed: 3 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -75,35 +75,13 @@ private Task<string> RunQueryAsync(UserQuery query)
7575
if (string.IsNullOrEmpty(query.Upn))
7676
{
7777
//Building user query
78-
//Required parameters will be set to default if not supplied by the test code
79-
80-
queryDict.Add(
81-
LabApiConstants.MultiFactorAuthentication,
82-
query.MFA != null ?
83-
query.MFA.ToString() :
84-
MFA.None.ToString());
85-
86-
queryDict.Add(
87-
LabApiConstants.ProtectionPolicy,
88-
query.ProtectionPolicy != null ?
89-
query.ProtectionPolicy.ToString() :
90-
ProtectionPolicy.None.ToString());
91-
78+
//Required parameters will be set to default if not supplied by the test code
79+
9280
if (query.UserType != null)
9381
{
9482
queryDict.Add(LabApiConstants.UserType, query.UserType.ToString());
9583
}
96-
97-
if (query.HomeDomain != null)
98-
{
99-
queryDict.Add(LabApiConstants.HomeDomain, query.HomeDomain.ToString());
100-
}
101-
102-
if (query.HomeUPN != null)
103-
{
104-
queryDict.Add(LabApiConstants.HomeUPN, query.HomeUPN.ToString());
105-
}
106-
84+
10785
if (query.B2CIdentityProvider != null)
10886
{
10987
queryDict.Add(LabApiConstants.B2CProvider, query.B2CIdentityProvider.ToString());
@@ -168,17 +146,6 @@ internal async Task<string> GetLabResponseAsync(string address)
168146
}
169147
}
170148

171-
public async Task<string> GetUserSecretAsync(string lab)
172-
{
173-
Dictionary<string, string> queryDict = new Dictionary<string, string>
174-
{
175-
{ "secret", lab }
176-
};
177-
178-
string result = await SendLabRequestAsync(LabApiConstants.LabUserCredentialEndpoint, queryDict).ConfigureAwait(false);
179-
return JsonConvert.DeserializeObject<LabCredentialResponse>(result).Secret;
180-
}
181-
182149
public async Task<string> GetMSIHelperServiceTokenAsync()
183150
{
184151
if (_msiHelperApiAccessToken == null)

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

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,6 @@ public class LabUser
1818
[JsonProperty("upn")]
1919
public string Upn { get; set; }
2020

21-
[JsonProperty("displayname")]
22-
public string DisplayName { get; set; }
23-
24-
[JsonProperty("mfa")]
25-
public MFA Mfa { get; set; }
26-
27-
[JsonProperty("protectionpolicy")]
28-
public ProtectionPolicy ProtectionPolicy { get; set; }
29-
30-
[JsonProperty("homedomain")]
31-
public HomeDomain HomeDomain { get; set; }
32-
3321
[JsonProperty("homeupn")]
3422
public string HomeUPN { get; set; }
3523

@@ -41,8 +29,6 @@ public class LabUser
4129

4230
public FederationProvider FederationProvider { get; set; }
4331

44-
public string Credential { get; set; }
45-
4632
public string TenantId { get; set; }
4733

4834
private string _password = null;

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

Lines changed: 1 addition & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -136,13 +136,7 @@ private static LabResponse MergeLabResponses(LabResponse primary, LabResponse se
136136

137137
return primaryJson.ToObject<LabResponse>();
138138
}
139-
140-
[Obsolete("Use GetSpecificUserAsync instead", true)]
141-
public static Task<LabResponse> GetLabUserDataForSpecificUserAsync(string upn)
142-
{
143-
throw new NotSupportedException();
144-
}
145-
139+
146140
public static async Task<string> GetMSIEnvironmentVariablesAsync(string uri)
147141
{
148142
string result = await s_labService.GetLabResponseAsync(uri).ConfigureAwait(false);
@@ -187,33 +181,6 @@ public static Task<LabResponse> GetB2CLocalAccountAsync()
187181
return GetLabUserDataAsync(UserQuery.B2CLocalAccountUserQuery);
188182
}
189183

190-
public static Task<LabResponse> GetB2CFacebookAccountAsync()
191-
{
192-
return GetLabUserDataAsync(UserQuery.B2CFacebookUserQuery);
193-
}
194-
195-
public static Task<LabResponse> GetB2CGoogleAccountAsync()
196-
{
197-
return GetLabUserDataAsync(UserQuery.B2CGoogleUserQuery);
198-
}
199-
200-
public static async Task<LabResponse> GetB2CMSAAccountAsync()
201-
{
202-
var response = await GetLabUserDataAsync(UserQuery.B2CMSAUserQuery).ConfigureAwait(false);
203-
if (string.IsNullOrEmpty(response.User.HomeUPN) ||
204-
string.Equals("None", response.User.HomeUPN, StringComparison.OrdinalIgnoreCase))
205-
{
206-
Debug.WriteLine($"B2C MSA HomeUPN set to UPN: {response.User.Upn}");
207-
response.User.HomeUPN = response.User.Upn;
208-
}
209-
return response;
210-
}
211-
212-
public static Task<LabResponse> GetSpecificUserAsync(string upn)
213-
{
214-
return GetLabUserDataAsync(new UserQuery() { Upn = upn });
215-
}
216-
217184
public static Task<LabResponse> GetArlingtonUserAsync()
218185
{
219186
var response = GetLabUserDataAsync(UserQuery.ArlingtonUserQuery);

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

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,6 @@ namespace Microsoft.Identity.Test.LabInfrastructure
99
public struct UserQuery
1010
{
1111
public UserType? UserType { get; set; }
12-
public MFA? MFA { get; set; }
13-
public ProtectionPolicy? ProtectionPolicy { get; set; }
14-
public HomeDomain? HomeDomain { get; set; }
15-
public HomeUPN? HomeUPN { get; set; }
1612
public B2CIdentityProvider? B2CIdentityProvider { get; set; }
1713
public FederationProvider? FederationProvider { get; set; } //Requires userType to be set to federated
1814
public AzureEnvironment? AzureEnvironment { get; set; }
@@ -51,24 +47,6 @@ public struct UserQuery
5147
B2CIdentityProvider = LabInfrastructure.B2CIdentityProvider.Local
5248
};
5349

54-
public static UserQuery B2CFacebookUserQuery => new UserQuery
55-
{
56-
UserType = LabInfrastructure.UserType.B2C,
57-
B2CIdentityProvider = LabInfrastructure.B2CIdentityProvider.Facebook
58-
};
59-
60-
public static UserQuery B2CGoogleUserQuery => new UserQuery
61-
{
62-
UserType = LabInfrastructure.UserType.B2C,
63-
B2CIdentityProvider = LabInfrastructure.B2CIdentityProvider.Google
64-
};
65-
66-
public static UserQuery B2CMSAUserQuery => new UserQuery
67-
{
68-
UserType = LabInfrastructure.UserType.B2C,
69-
B2CIdentityProvider = LabInfrastructure.B2CIdentityProvider.MSA
70-
};
71-
7250
public static UserQuery ArlingtonUserQuery => new UserQuery
7351
{
7452
UserType = LabInfrastructure.UserType.Cloud,

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

Lines changed: 0 additions & 7 deletions
This file was deleted.

0 commit comments

Comments
 (0)