Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -350,17 +350,17 @@ public static void AddManagedIdentityMockHandler(

if (userAssignedIdentityId == UserAssignedIdentityId.ClientId)
{
httpMessageHandler.ExpectedQueryParams.Add("client_id", userAssignedId);
httpMessageHandler.ExpectedQueryParams.Add(TestConstants.ManagedIdentityClientId, userAssignedId);
}

if (userAssignedIdentityId == UserAssignedIdentityId.ResourceId)
{
httpMessageHandler.ExpectedQueryParams.Add("mi_res_id", userAssignedId);
httpMessageHandler.ExpectedQueryParams.Add(TestConstants.ManagedIdentityResourceId, userAssignedId);
}

if (userAssignedIdentityId == UserAssignedIdentityId.ObjectId)
{
httpMessageHandler.ExpectedQueryParams.Add("object_id", userAssignedId);
httpMessageHandler.ExpectedQueryParams.Add(TestConstants.ManagedIdentityObjectId, userAssignedId);
}

httpMessageHandler.ResponseMessage = responseMessage;
Expand Down
4 changes: 4 additions & 0 deletions tests/Microsoft.Identity.Test.Common/TestConstants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,10 @@ public static IDictionary<string, string> ExtraQueryParameters
public const string MsalArlingtonCCAKeyVaultUri = "https://msidlabs.vault.azure.net:443/secrets/ARLMSIDLAB1-IDLASBS-App-CC-Secret";
public const string MsalArlingtonCCAKeyVaultSecretName = "ARLMSIDLAB1-IDLASBS-App-CC-Secret";

public const string ManagedIdentityClientId = "client_id";
public const string ManagedIdentityObjectId = "object_id";
public const string ManagedIdentityResourceId = "mi_res_id";

public enum AuthorityType { B2C };
public static string[] s_prodEnvAliases = new[] {
"login.microsoftonline.com",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,26 +85,14 @@ public void TestConstructor_WithCreateUserAssignedId()
[DataRow("resourceId", UserAssignedIdentityId.ResourceId)]
[DataRow("resourceId/subscription", UserAssignedIdentityId.ResourceId)]
[DataRow(TestConstants.ObjectId, UserAssignedIdentityId.ObjectId)]
public void TestConstructor_WithUserAssignedManagedIdentity_ResourceId(string userAssignedId, UserAssignedIdentityId userAssignedIdentityId)
public void TestConstructor_WithUserAssignedManagedIdentity(string userAssignedId, UserAssignedIdentityId userAssignedIdentityId)
{
ManagedIdentityApplication mi = CreateMIABuilder(userAssignedId, userAssignedIdentityId).BuildConcrete();

Assert.AreEqual(userAssignedId, mi.ServiceBundle.Config.ClientId);
Assert.IsNotNull(mi.ServiceBundle.Config.ManagedIdentityId);

if (userAssignedIdentityId == UserAssignedIdentityId.ClientId)
{
Assert.AreEqual(ManagedIdentityIdType.ClientId, mi.ServiceBundle.Config.ManagedIdentityId.IdType);
}
else if(userAssignedIdentityId == UserAssignedIdentityId.ResourceId)
{
Assert.AreEqual(ManagedIdentityIdType.ResourceId, mi.ServiceBundle.Config.ManagedIdentityId.IdType);
}
else
{
Assert.AreEqual(ManagedIdentityIdType.ObjectId, mi.ServiceBundle.Config.ManagedIdentityId.IdType);
}


Assert.AreEqual(userAssignedIdentityId.ToString(), mi.ServiceBundle.Config.ManagedIdentityId.IdType.ToString());
Assert.AreEqual(userAssignedId, mi.ServiceBundle.Config.ManagedIdentityId.UserAssignedId);
}

Expand Down