diff --git a/src/Accounts/Accounts.Test/AzureRMProfileTests.cs b/src/Accounts/Accounts.Test/AzureRMProfileTests.cs index 0ad30c46bb60..22615f71026e 100644 --- a/src/Accounts/Accounts.Test/AzureRMProfileTests.cs +++ b/src/Accounts/Accounts.Test/AzureRMProfileTests.cs @@ -20,7 +20,7 @@ using Microsoft.Azure.Commands.Profile.Models; using Microsoft.Azure.Commands.Profile.Test; using Microsoft.Azure.Commands.ScenarioTest; -using Microsoft.Azure.Management.ResourceManager.Version2019_06_01.Models; +using Microsoft.Azure.Management.ResourceManager.Version2021_01_01.Models; using Microsoft.Azure.ServiceManagement.Common.Models; using Microsoft.Rest; using Microsoft.Rest.Azure; @@ -62,7 +62,7 @@ private static RMProfileClient SetupTestEnvironment(List tenants, params var clientFactory = new MockSubscriptionClientFactory(tenants, subscriptionList); var mock = new MockClientFactory(new List { - clientFactory.GetSubscriptionClientVer2019(), + clientFactory.GetSubscriptionClientVerLatest(), clientFactory.GetSubscriptionClientVer2016() }, true); mock.MoqClients = true; @@ -90,7 +90,7 @@ private static AzureRmProfile SetupLogin(List tenants, params List { - clientFactory.GetSubscriptionClientVer2019(), + clientFactory.GetSubscriptionClientVerLatest(), clientFactory.GetSubscriptionClientVer2016() }, true); mock.MoqClients = true; @@ -144,7 +144,7 @@ public void SpecifyTenantAndSubscriptionIdSucceed() null, false, null); - Assert.Equal("2019-06-01", client.SubscriptionAndTenantClient.ApiVersion); + Assert.Equal("2021-01-01", client.SubscriptionAndTenantClient.ApiVersion); } [Fact] @@ -164,8 +164,8 @@ public void SubscriptionIdNotExist() TenantId = DefaultTenant.ToString() }; - MockSubscriptionClientFactory.SubGetQueueVer2019 = new Queue>>(); - MockSubscriptionClientFactory.SubGetQueueVer2019.Enqueue(() => + MockSubscriptionClientFactory.SubGetQueueVerLatest = new Queue>>(); + MockSubscriptionClientFactory.SubGetQueueVerLatest.Enqueue(() => { throw new CloudException("InvalidAuthenticationTokenTenant: The access token is from the wrong issuer"); }); @@ -179,7 +179,7 @@ public void SubscriptionIdNotExist() null, false, null)); - Assert.Equal("2019-06-01", client.SubscriptionAndTenantClient.ApiVersion); + Assert.Equal("2021-01-01", client.SubscriptionAndTenantClient.ApiVersion); } [Fact] @@ -230,8 +230,8 @@ public void SubscriptionIdNotInFirstTenant() TenantId = DefaultTenant.ToString() }; - MockSubscriptionClientFactory.SubGetQueueVer2019 = new Queue>>(); - MockSubscriptionClientFactory.SubGetQueueVer2019.Enqueue(() => + MockSubscriptionClientFactory.SubGetQueueVerLatest = new Queue>>(); + MockSubscriptionClientFactory.SubGetQueueVerLatest.Enqueue(() => { throw new CloudException("InvalidAuthenticationTokenTenant: The access token is from the wrong issuer"); }); @@ -266,8 +266,8 @@ public void SubscriptionNameNotInFirstTenant() TenantId = DefaultTenant.ToString() }; - MockSubscriptionClientFactory.SubListQueueVer2019 = new Queue>>>(); - MockSubscriptionClientFactory.SubListQueueVer2019.Enqueue(() => + MockSubscriptionClientFactory.SubListQueueVerLatest = new Queue>>>(); + MockSubscriptionClientFactory.SubListQueueVerLatest.Enqueue(() => { var sub1 = new Subscription( id: DefaultSubscription.ToString(), diff --git a/src/Accounts/Accounts.Test/AzureRMProfileTestsForMultitenant.cs b/src/Accounts/Accounts.Test/AzureRMProfileTestsForMultitenant.cs index a1931913369c..fb9c70f76ec6 100644 --- a/src/Accounts/Accounts.Test/AzureRMProfileTestsForMultitenant.cs +++ b/src/Accounts/Accounts.Test/AzureRMProfileTestsForMultitenant.cs @@ -15,6 +15,7 @@ using Microsoft.Azure.Commands.Common.Authentication; using Microsoft.Azure.Commands.Common.Authentication.Abstractions; using Microsoft.Azure.Commands.Common.Authentication.Models; +using Microsoft.Azure.Commands.Profile.Models; using Microsoft.Azure.Commands.Profile.Test.Mocks; using Microsoft.Azure.Commands.ScenarioTest; using Microsoft.Azure.ServiceManagement.Common.Models; @@ -30,7 +31,7 @@ namespace Microsoft.Azure.Commands.ResourceManager.Common.Test { - public class AzureRMProfileTestsForMultitenant + public class AzureRMProfileTestsForMultitenant : IDisposable { private const string DefaultAccount = "admin@contoso.com"; private static Guid DefaultSubscription = Guid.NewGuid(); @@ -58,6 +59,11 @@ public AzureRMProfileTestsForMultitenant(ITestOutputHelper output) }; } + public void Dispose() + { + SubscritpionClientCandidates.Reset(); + } + private RMProfileClient GetProfileClient() { var sub = new AzureSubscription() @@ -276,7 +282,7 @@ public void LoginByTenant() Dictionary subscriptionList = GetFirstTenantSubscriptionsJson(tenantA, subscriptionA, subscriptionB, subscriptionC, tenantB); subscriptionClients.Clear(); - subscriptionClients.Enqueue(clientFactory.GetSubscriptionClientVer2019( + subscriptionClients.Enqueue(clientFactory.GetSubscriptionClientVerLatest( null , null , MockSubscriptionClientFactory.CreateSubscriptionListsFromJson(subscriptionList.Values.ToList()) @@ -301,7 +307,7 @@ public void LoginByTenant() false, null); - Assert.Equal("2019-06-01", client.SubscriptionAndTenantClient.ApiVersion); + Assert.Equal("2021-01-01", client.SubscriptionAndTenantClient.ApiVersion); Assert.Equal(tenantA, azureRmProfile.DefaultContext.Tenant.Id.ToString()); Assert.Equal(subscriptionA, azureRmProfile.DefaultContext.Subscription.Id.ToString()); } @@ -320,7 +326,7 @@ public void LoginBySubscriptionInMultitenantsHomeFirst() var subscriptionListA = GetFirstTenantSubscriptionsJson(tenantA, subscriptionA, subscriptionB, subscriptionC, tenantB); var subscriptionListB = GetSecondTenantSubscriptionsJson(tenantB, subscriptionA, subscriptionB, subscriptionC, subscriptionD, tenantA); subscriptionClients.Clear(); - subscriptionClients.Enqueue(clientFactory.GetSubscriptionClientVer2019( + subscriptionClients.Enqueue(clientFactory.GetSubscriptionClientVerLatest( MockSubscriptionClientFactory.CreateTenantListFromJson(GetTenantsJson(tenantA, tenantB).Values.ToArray()) , MockSubscriptionClientFactory.CreateSubscripitonsFromJson(subscriptionListA[subscriptionA], subscriptionListB[subscriptionA]) , null @@ -344,7 +350,7 @@ public void LoginBySubscriptionInMultitenantsHomeFirst() false, null); - Assert.Equal("2019-06-01", client.SubscriptionAndTenantClient.ApiVersion); + Assert.Equal("2021-01-01", client.SubscriptionAndTenantClient.ApiVersion); Assert.Equal(tenantA, azureRmProfile.DefaultContext.Tenant.Id.ToString()); Assert.Equal(subscriptionA, azureRmProfile.DefaultContext.Subscription.Id.ToString()); } @@ -364,7 +370,7 @@ public void LoginBySubscriptionInMultitenantsHomeSecond() var subscriptionListA = GetFirstTenantSubscriptionsJson(tenantA, subscriptionA, subscriptionB, subscriptionC, tenantB); var subscriptionListB = GetSecondTenantSubscriptionsJson(tenantB, subscriptionA, subscriptionB, subscriptionC, subscriptionD, tenantA); subscriptionClients.Clear(); - subscriptionClients.Enqueue(clientFactory.GetSubscriptionClientVer2019( + subscriptionClients.Enqueue(clientFactory.GetSubscriptionClientVerLatest( MockSubscriptionClientFactory.CreateTenantListFromJson(tenantList[tenantB], tenantList[tenantA]) , null , MockSubscriptionClientFactory.CreateSubscriptionListsFromJson(subscriptionListB.Values.ToList(), subscriptionListA.Values.ToList()) @@ -390,7 +396,7 @@ public void LoginBySubscriptionInMultitenantsHomeSecond() false, null); - Assert.Equal("2019-06-01", client.SubscriptionAndTenantClient.ApiVersion); + Assert.Equal("2021-01-01", client.SubscriptionAndTenantClient.ApiVersion); Assert.Equal(tenantA, azureRmProfile.DefaultContext.Tenant.Id.ToString()); Assert.Equal(subscriptionA, azureRmProfile.DefaultContext.Subscription.Id.ToString()); } @@ -409,7 +415,7 @@ public void LoginBySubscriptionInManagedByTenants() Dictionary subscriptionListA = GetFirstTenantSubscriptionsJson(tenantA, subscriptionA, subscriptionB, subscriptionC, tenantB); Dictionary subscriptionListB = GetSecondTenantSubscriptionsJson(tenantB, subscriptionA, subscriptionB, subscriptionC, subscriptionD, tenantA); subscriptionClients.Clear(); - subscriptionClients.Enqueue(clientFactory.GetSubscriptionClientVer2019( + subscriptionClients.Enqueue(clientFactory.GetSubscriptionClientVerLatest( MockSubscriptionClientFactory.CreateTenantListFromJson(GetTenantsJson(tenantA, tenantB).Values.ToArray()) , null , MockSubscriptionClientFactory.CreateSubscriptionListsFromJson(subscriptionListA.Values.ToList(), subscriptionListB.Values.ToList()) @@ -434,7 +440,7 @@ public void LoginBySubscriptionInManagedByTenants() false, null); - Assert.Equal("2019-06-01", client.SubscriptionAndTenantClient.ApiVersion); + Assert.Equal("2021-01-01", client.SubscriptionAndTenantClient.ApiVersion); Assert.Equal(tenantB, azureRmProfile.DefaultContext.Tenant.Id.ToString()); Assert.Equal(subscriptionC, azureRmProfile.DefaultContext.Subscription.Id.ToString()); } @@ -452,7 +458,7 @@ public void LoginBySubscriptionTenant() Dictionary subscriptionListA = GetFirstTenantSubscriptionsJson(tenantA, subscriptionA, subscriptionB, subscriptionC, tenantB); subscriptionClients.Clear(); - subscriptionClients.Enqueue(clientFactory.GetSubscriptionClientVer2019( + subscriptionClients.Enqueue(clientFactory.GetSubscriptionClientVerLatest( null , MockSubscriptionClientFactory.CreateSubscripitonsFromJson(subscriptionListA[subscriptionB]) , null @@ -477,7 +483,7 @@ public void LoginBySubscriptionTenant() false, null); - Assert.Equal("2019-06-01", client.SubscriptionAndTenantClient.ApiVersion); + Assert.Equal("2021-01-01", client.SubscriptionAndTenantClient.ApiVersion); Assert.Equal(tenantA, azureRmProfile.DefaultContext.Tenant.Id.ToString()); Assert.Equal(subscriptionB, azureRmProfile.DefaultContext.Subscription.Id.ToString()); } @@ -496,7 +502,7 @@ public void LoginByTenantSubscriptionNotExist() Dictionary subscriptionListA = GetFirstTenantSubscriptionsJson(tenantA, subscriptionA, subscriptionB, subscriptionC, tenantB); Dictionary subscriptionListB = GetSecondTenantSubscriptionsJson(tenantB, subscriptionA, subscriptionB, subscriptionC, subscriptionD, tenantA); subscriptionClients.Clear(); - subscriptionClients.Enqueue(clientFactory.GetSubscriptionClientVer2019( + subscriptionClients.Enqueue(clientFactory.GetSubscriptionClientVerLatest( null , MockSubscriptionClientFactory.CreateSubscripitonsFromJson(null) , null @@ -537,7 +543,7 @@ public void LoginSubscriptionNameNotExist() Dictionary subscriptionListA = GetFirstTenantSubscriptionsJson(tenantA, subscriptionA, subscriptionB, subscriptionC, tenantB); Dictionary subscriptionListB = GetSecondTenantSubscriptionsJson(tenantB, subscriptionA, subscriptionB, subscriptionC, subscriptionD, tenantA); subscriptionClients.Clear(); - subscriptionClients.Enqueue(clientFactory.GetSubscriptionClientVer2019( + subscriptionClients.Enqueue(clientFactory.GetSubscriptionClientVerLatest( MockSubscriptionClientFactory.CreateTenantListFromJson(GetTenantsJson(tenantA, tenantB).Values.ToArray()) , null , MockSubscriptionClientFactory.CreateSubscriptionListsFromJson(subscriptionListA.Values.ToList(), subscriptionListB.Values.ToList()) @@ -574,7 +580,7 @@ public void SetContextByValidTenant() Dictionary subscriptionList = GetFirstTenantSubscriptionsJson(tenantA, subscriptionA, subscriptionB, subscriptionC, tenantB); subscriptionClients.Clear(); - subscriptionClients.Enqueue(clientFactory.GetSubscriptionClientVer2019( + subscriptionClients.Enqueue(clientFactory.GetSubscriptionClientVerLatest( null , null , MockSubscriptionClientFactory.CreateSubscriptionListsFromJson(subscriptionList.Values.ToList()) @@ -591,7 +597,7 @@ public void SetContextByValidTenant() var client = GetProfileClient(); var context = client.SetCurrentContext(null, tenantA); - Assert.Equal("2019-06-01", client.SubscriptionAndTenantClient.ApiVersion); + Assert.Equal("2021-01-01", client.SubscriptionAndTenantClient.ApiVersion); Assert.Equal(tenantA, context.Tenant.Id.ToString()); Assert.Equal(subscriptionA, context.Subscription.Id.ToString()); } @@ -611,7 +617,7 @@ public void SetContextBySubscriptionIdInHomeTenant() var subscriptionListA = GetFirstTenantSubscriptionsJson(tenantA, subscriptionA, subscriptionB, subscriptionC, tenantB); var subscriptionListB = GetSecondTenantSubscriptionsJson(tenantB, subscriptionA, subscriptionB, subscriptionC, subscriptionD, tenantA); subscriptionClients.Clear(); - subscriptionClients.Enqueue(clientFactory.GetSubscriptionClientVer2019( + subscriptionClients.Enqueue(clientFactory.GetSubscriptionClientVerLatest( MockSubscriptionClientFactory.CreateTenantListFromJson(GetTenantsJson(tenantA, tenantB).Values.ToArray()) , null , MockSubscriptionClientFactory.CreateSubscriptionListsFromJson(subscriptionListB.Values.ToList(), subscriptionListA.Values.ToList()) @@ -627,7 +633,7 @@ public void SetContextBySubscriptionIdInHomeTenant() var client = GetProfileClient(); var context = client.SetCurrentContext(subscriptionA, null); - Assert.Equal("2019-06-01", client.SubscriptionAndTenantClient.ApiVersion); + Assert.Equal("2021-01-01", client.SubscriptionAndTenantClient.ApiVersion); Assert.Equal(tenantA, context.Tenant.Id.ToString()); Assert.Equal(subscriptionA, context.Subscription.Id.ToString()); } @@ -647,7 +653,7 @@ public void SetContextBySubscriptionNameInHomeTenant() var subscriptionListA = GetFirstTenantSubscriptionsJson(tenantA, subscriptionA, subscriptionB, subscriptionC, tenantB); var subscriptionListB = GetSecondTenantSubscriptionsJson(tenantB, subscriptionA, subscriptionB, subscriptionC, subscriptionD, tenantA); subscriptionClients.Clear(); - subscriptionClients.Enqueue(clientFactory.GetSubscriptionClientVer2019( + subscriptionClients.Enqueue(clientFactory.GetSubscriptionClientVerLatest( MockSubscriptionClientFactory.CreateTenantListFromJson(tenantList[tenantB], tenantList[tenantA]) , null , MockSubscriptionClientFactory.CreateSubscriptionListsFromJson(subscriptionListA.Values.ToList(), subscriptionListB.Values.ToList()) @@ -664,7 +670,7 @@ public void SetContextBySubscriptionNameInHomeTenant() var client = GetProfileClient(); var context = client.SetCurrentContext(subscriptionName.ToString(), null); - Assert.Equal("2019-06-01", client.SubscriptionAndTenantClient.ApiVersion); + Assert.Equal("2021-01-01", client.SubscriptionAndTenantClient.ApiVersion); Assert.Equal(tenantA, context.Tenant.Id.ToString()); Assert.Equal(subscriptionA, context.Subscription.Id.ToString()); } @@ -683,7 +689,7 @@ public void SetContextBySubscriptionInManagedByTenants() Dictionary subscriptionListA = GetFirstTenantSubscriptionsJson(tenantA, subscriptionA, subscriptionB, subscriptionC, tenantB); Dictionary subscriptionListB = GetSecondTenantSubscriptionsJson(tenantB, subscriptionA, subscriptionB, subscriptionC, subscriptionD, tenantA); subscriptionClients.Clear(); - subscriptionClients.Enqueue(clientFactory.GetSubscriptionClientVer2019( + subscriptionClients.Enqueue(clientFactory.GetSubscriptionClientVerLatest( MockSubscriptionClientFactory.CreateTenantListFromJson(GetTenantsJson(tenantA, tenantB).Values.ToArray()) , null , MockSubscriptionClientFactory.CreateSubscriptionListsFromJson(subscriptionListA.Values.ToList(), subscriptionListB.Values.ToList()) @@ -699,7 +705,7 @@ public void SetContextBySubscriptionInManagedByTenants() var client = GetProfileClient(); var context = client.SetCurrentContext(subscriptionC.ToString(), null); - Assert.Equal("2019-06-01", client.SubscriptionAndTenantClient.ApiVersion); + Assert.Equal("2021-01-01", client.SubscriptionAndTenantClient.ApiVersion); Assert.Equal(tenantA, context.Tenant.Id.ToString()); Assert.Equal(subscriptionC, context.Subscription.Id.ToString()); } @@ -717,7 +723,7 @@ public void SetContextBySubscriptionTenant() Dictionary subscriptionListA = GetFirstTenantSubscriptionsJson(tenantA, subscriptionA, subscriptionB, subscriptionC, tenantB); subscriptionClients.Clear(); - subscriptionClients.Enqueue(clientFactory.GetSubscriptionClientVer2019( + subscriptionClients.Enqueue(clientFactory.GetSubscriptionClientVerLatest( null , null , MockSubscriptionClientFactory.CreateSubscriptionListsFromJson(subscriptionListA.Values.ToList()) @@ -735,7 +741,7 @@ public void SetContextBySubscriptionTenant() var subscriptionName = (JObject.Parse(subscriptionListA[subscriptionB]))["displayName"]; var context = client.SetCurrentContext(subscriptionName.ToString(), tenantA); - Assert.Equal("2019-06-01", client.SubscriptionAndTenantClient.ApiVersion); + Assert.Equal("2021-01-01", client.SubscriptionAndTenantClient.ApiVersion); Assert.Equal(tenantA, context.Tenant.Id.ToString()); Assert.Equal(subscriptionB, context.Subscription.Id.ToString()); } @@ -752,7 +758,7 @@ public void SetContextBySubscriptionTenantNotExist() Dictionary subscriptionListB = GetSecondTenantSubscriptionsJson(tenantB, subscriptionA, subscriptionB, subscriptionC, subscriptionD, tenantA); subscriptionClients.Clear(); - subscriptionClients.Enqueue(clientFactory.GetSubscriptionClientVer2019( + subscriptionClients.Enqueue(clientFactory.GetSubscriptionClientVerLatest( null , null , MockSubscriptionClientFactory.CreateSubscriptionListsFromJson(subscriptionListB.Values.ToList()) diff --git a/src/Accounts/Accounts.Test/Mocks/MockSubscriptionClientFactory.cs b/src/Accounts/Accounts.Test/Mocks/MockSubscriptionClientFactory.cs index 0f525fab3226..ff87519ed830 100644 --- a/src/Accounts/Accounts.Test/Mocks/MockSubscriptionClientFactory.cs +++ b/src/Accounts/Accounts.Test/Mocks/MockSubscriptionClientFactory.cs @@ -12,8 +12,8 @@ // limitations under the License. // ---------------------------------------------------------------------------------- -using Microsoft.Azure.Management.ResourceManager.Version2019_06_01; -using Microsoft.Azure.Management.ResourceManager.Version2019_06_01.Models; +using Microsoft.Azure.Management.ResourceManager.Version2021_01_01; +using Microsoft.Azure.Management.ResourceManager.Version2021_01_01.Models; using Microsoft.Rest.Azure; using Moq; using System; diff --git a/src/Accounts/Accounts.Test/Mocks/MockSubscriptionClientFactoryVersion2019.cs b/src/Accounts/Accounts.Test/Mocks/MockSubscriptionClientFactoryVersion2019.cs index e50a8ddd74b9..022fbf706024 100644 --- a/src/Accounts/Accounts.Test/Mocks/MockSubscriptionClientFactoryVersion2019.cs +++ b/src/Accounts/Accounts.Test/Mocks/MockSubscriptionClientFactoryVersion2019.cs @@ -12,8 +12,8 @@ // limitations under the License. // ---------------------------------------------------------------------------------- -using Microsoft.Azure.Management.ResourceManager.Version2019_06_01; -using Microsoft.Azure.Management.ResourceManager.Version2019_06_01.Models; +using Microsoft.Azure.Management.ResourceManager.Version2021_01_01; +using Microsoft.Azure.Management.ResourceManager.Version2021_01_01.Models; using Microsoft.Rest.Azure; using Moq; using System; @@ -29,24 +29,24 @@ namespace Microsoft.Azure.Commands.ResourceManager.Common.Test { public partial class MockSubscriptionClientFactory { - public static Queue>> SubGetQueueVer2019 { get; set; } = null; - public static Queue>>> SubListQueueVer2019 { get; set; } = null; - public static Queue>>> TenantListQueueVer2019 { get; set; } = null; + public static Queue>> SubGetQueueVerLatest { get; set; } = null; + public static Queue>>> SubListQueueVerLatest { get; set; } = null; + public static Queue>>> TenantListQueueVerLatest { get; set; } = null; - public DeGetAsyncQueue GetSubQueueDequeueVer2019 = () => Task.FromResult(SubGetQueueVer2019.Dequeue().Invoke()); - public DeListAsyncQueue ListSubQueueDequeueVer2019 = () => Task.FromResult(SubListQueueVer2019.Dequeue().Invoke()); - public DeListAsyncQueue ListTenantQueueDequeueVer2019 = () => Task.FromResult(TenantListQueueVer2019.Dequeue().Invoke()); + public DeGetAsyncQueue GetSubQueueDequeueVerLatest = () => Task.FromResult(SubGetQueueVerLatest.Dequeue().Invoke()); + public DeListAsyncQueue ListSubQueueDequeueVerLatest = () => Task.FromResult(SubListQueueVerLatest.Dequeue().Invoke()); + public DeListAsyncQueue ListTenantQueueDequeueVerLatest = () => Task.FromResult(TenantListQueueVerLatest.Dequeue().Invoke()); - public SubscriptionClient GetSubscriptionClientVer2019() + public SubscriptionClient GetSubscriptionClientVerLatest() { var tenantMock = new Mock(); tenantMock.Setup(t => t.ListWithHttpMessagesAsync(It.IsAny>>(), It.IsAny())) .Returns( (Dictionary> ch, CancellationToken token) => { - if(TenantListQueueVer2019 != null && TenantListQueueVer2019.Any()) + if(TenantListQueueVerLatest != null && TenantListQueueVerLatest.Any()) { - return ListTenantQueueDequeueVer2019(); + return ListTenantQueueDequeueVerLatest(); } var tenants = _tenants.Select((k) => new TenantIdDescription(id: k, tenantId: k)); var mockPage = new MockPage(tenants.ToList()); @@ -64,9 +64,9 @@ public SubscriptionClient GetSubscriptionClientVer2019() s => s.GetWithHttpMessagesAsync(It.IsAny(), It.IsAny>>(), It.IsAny())).Returns( (string subId, Dictionary> ch, CancellationToken token) => { - if (SubGetQueueVer2019 != null && SubGetQueueVer2019.Any()) + if (SubGetQueueVerLatest != null && SubGetQueueVerLatest.Any()) { - return GetSubQueueDequeueVer2019(); + return GetSubQueueDequeueVerLatest(); } AzureOperationResponse result = new AzureOperationResponse { @@ -91,9 +91,9 @@ public SubscriptionClient GetSubscriptionClientVer2019() (s) => s.ListWithHttpMessagesAsync(null, It.IsAny())).Returns( (Dictionary> ch, CancellationToken token) => { - if (SubListQueueVer2019 != null && SubListQueueVer2019.Any()) + if (SubListQueueVerLatest != null && SubListQueueVerLatest.Any()) { - return ListSubQueueDequeueVer2019(); + return ListSubQueueDequeueVerLatest(); } AzureOperationResponse> result = null; @@ -160,9 +160,9 @@ private ITenantsOperations GetTenantMock(List tenants) .Returns( (Dictionary> ch, CancellationToken token) => { - if (TenantListQueueVer2019 != null && TenantListQueueVer2019.Any()) + if (TenantListQueueVerLatest != null && TenantListQueueVerLatest.Any()) { - return ListTenantQueueDequeueVer2019(); + return ListTenantQueueDequeueVerLatest(); } var mockPage = new MockPage(tenants); @@ -190,9 +190,9 @@ private ISubscriptionsOperations GetSubscriptionMock(List subscrip s => s.GetWithHttpMessagesAsync(It.IsAny(), It.IsAny>>(), It.IsAny())).Returns( (string subId, Dictionary> ch, CancellationToken token) => { - if (SubGetQueueVer2019 != null && SubGetQueueVer2019.Any()) + if (SubGetQueueVerLatest != null && SubGetQueueVerLatest.Any()) { - return GetSubQueueDequeueVer2019(); + return GetSubQueueDequeueVerLatest(); } AzureOperationResponse result = new AzureOperationResponse() { @@ -210,9 +210,9 @@ private ISubscriptionsOperations GetSubscriptionMock(List subscrip (s) => s.ListWithHttpMessagesAsync(null, It.IsAny())).Returns( (Dictionary> ch, CancellationToken token) => { - if (SubListQueueVer2019 != null && SubListQueueVer2019.Any()) + if (SubListQueueVerLatest != null && SubListQueueVerLatest.Any()) { - return ListSubQueueDequeueVer2019(); + return ListSubQueueDequeueVerLatest(); } AzureOperationResponse> result = null; @@ -249,7 +249,7 @@ private ISubscriptionsOperations GetSubscriptionMock(List subscrip return subscriptionMock.Object; } - public SubscriptionClient GetSubscriptionClientVer2019(List tenants, List subscriptionGetList, List> subscriptionListLists, List HasNextPage = null) + public SubscriptionClient GetSubscriptionClientVerLatest(List tenants, List subscriptionGetList, List> subscriptionListLists, List HasNextPage = null) { var client = new Mock() { CallBase = true }; if (subscriptionGetList != null || subscriptionListLists != null) diff --git a/src/Accounts/Accounts.Test/SessionRecords/Microsoft.Azure.Commands.Profile.Test.SubscriptionCmdletTests/GetSubscriptionsWithTags.json b/src/Accounts/Accounts.Test/SessionRecords/Microsoft.Azure.Commands.Profile.Test.SubscriptionCmdletTests/GetSubscriptionsWithTags.json new file mode 100644 index 000000000000..570c11d0ba73 --- /dev/null +++ b/src/Accounts/Accounts.Test/SessionRecords/Microsoft.Azure.Commands.Profile.Test.SubscriptionCmdletTests/GetSubscriptionsWithTags.json @@ -0,0 +1,128 @@ +{ + "Entries": [ + { + "RequestUri": "/tenants?api-version=2021-01-01", + "EncodedRequestUri": "L3RlbmFudHM/YXBpLXZlcnNpb249MjAyMS0wMS0wMQ==", + "RequestMethod": "GET", + "RequestBody": "", + "RequestHeaders": { + "x-ms-client-request-id": [ + "27447c0a-62f3-4ec5-a2ee-46d57196a6c5" + ], + "Accept-Language": [ + "en-US" + ], + "User-Agent": [ + "FxVersion/4.6.30015.01", + "OSName/Windows", + "OSVersion/Microsoft.Windows.10.0.19043.", + "Microsoft.Azure.Management.ResourceManager.Version2021.01.01.SubscriptionClient/1.0.0.0" + ] + }, + "ResponseHeaders": { + "Cache-Control": [ + "no-cache" + ], + "Pragma": [ + "no-cache" + ], + "x-ms-ratelimit-remaining-tenant-reads": [ + "11999" + ], + "x-ms-request-id": [ + "aa195b95-77d4-41fe-81ae-041fde762974" + ], + "x-ms-correlation-request-id": [ + "aa195b95-77d4-41fe-81ae-041fde762974" + ], + "x-ms-routing-request-id": [ + "SOUTHEASTASIA:20210628T075523Z:aa195b95-77d4-41fe-81ae-041fde762974" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubDomains" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "Date": [ + "Mon, 28 Jun 2021 07:55:23 GMT" + ], + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Expires": [ + "-1" + ], + "Content-Length": [ + "140" + ] + }, + "ResponseBody": "{\r\n \"value\": [\r\n {\r\n \"id\": \"/tenants/54826b22-38d6-4fb2-bad9-b7b93a3e9c5a\",\r\n \"tenantId\": \"54826b22-38d6-4fb2-bad9-b7b93a3e9c5a\",\r\n \"tenantCategory\": \"Home\"\r\n }\r\n ]\r\n}", + "StatusCode": 200 + }, + { + "RequestUri": "/subscriptions?api-version=2021-01-01", + "EncodedRequestUri": "L3N1YnNjcmlwdGlvbnM/YXBpLXZlcnNpb249MjAyMS0wMS0wMQ==", + "RequestMethod": "GET", + "RequestBody": "", + "RequestHeaders": { + "x-ms-client-request-id": [ + "27447c0a-62f3-4ec5-a2ee-46d57196a6c5" + ], + "Accept-Language": [ + "en-US" + ], + "User-Agent": [ + "FxVersion/4.6.30015.01", + "OSName/Windows", + "OSVersion/Microsoft.Windows.10.0.19043.", + "Microsoft.Azure.Management.ResourceManager.Version2021.01.01.SubscriptionClient/1.0.0.0" + ] + }, + "ResponseHeaders": { + "Cache-Control": [ + "no-cache" + ], + "Pragma": [ + "no-cache" + ], + "x-ms-ratelimit-remaining-tenant-reads": [ + "11999" + ], + "x-ms-request-id": [ + "c8cf462f-f2c0-4ef4-8dc3-aee3d36d3293" + ], + "x-ms-correlation-request-id": [ + "c8cf462f-f2c0-4ef4-8dc3-aee3d36d3293" + ], + "x-ms-routing-request-id": [ + "SOUTHEASTASIA:20210628T075524Z:c8cf462f-f2c0-4ef4-8dc3-aee3d36d3293" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubDomains" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "Date": [ + "Mon, 28 Jun 2021 07:55:23 GMT" + ], + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Expires": [ + "-1" + ], + "Content-Length": [ + "522" + ] + }, + "ResponseBody": "{\r\n \"value\": [\r\n {\r\n \"id\": \"/subscriptions/0b1f6471-1bf0-4dda-aec3-cb9272f09590\",\r\n \"authorizationSource\": \"RoleBased\",\r\n \"managedByTenants\": [\r\n {\r\n \"tenantId\": \"2f4a9838-26b7-47ee-be60-ccc1fdec5953\"\r\n }\r\n ],\r\n \"tags\": {\r\n \"testTags\": \"testValue\"\r\n },\r\n \"subscriptionId\": \"0b1f6471-1bf0-4dda-aec3-cb9272f09590\",\r\n \"tenantId\": \"54826b22-38d6-4fb2-bad9-b7b93a3e9c5a\",\r\n \"displayName\": \"AzureSDKTest\",\r\n \"state\": \"Enabled\",\r\n \"subscriptionPolicies\": {\r\n \"locationPlacementId\": \"Internal_2014-09-01\",\r\n \"quotaId\": \"Internal_2014-09-01\",\r\n \"spendingLimit\": \"Off\"\r\n }\r\n }\r\n ],\r\n \"count\": {\r\n \"type\": \"Total\",\r\n \"value\": 1\r\n }\r\n}", + "StatusCode": 200 + } + ], + "Names": {}, + "Variables": { + "SubscriptionId": "0b1f6471-1bf0-4dda-aec3-cb9272f09590" + } +} \ No newline at end of file diff --git a/src/Accounts/Accounts.Test/SubscriptionClientSwitchTest.cs b/src/Accounts/Accounts.Test/SubscriptionClientSwitchTest.cs index fa373d89780a..b6a339d36fc3 100644 --- a/src/Accounts/Accounts.Test/SubscriptionClientSwitchTest.cs +++ b/src/Accounts/Accounts.Test/SubscriptionClientSwitchTest.cs @@ -15,9 +15,10 @@ using Microsoft.Azure.Commands.Common.Authentication; using Microsoft.Azure.Commands.Common.Authentication.Abstractions; using Microsoft.Azure.Commands.Common.Authentication.Models; +using Microsoft.Azure.Commands.Profile.Models; using Microsoft.Azure.Commands.Profile.Test.Mocks; using Microsoft.Azure.Commands.ScenarioTest; -using Microsoft.Azure.Management.ResourceManager.Version2019_06_01.Models; +using Microsoft.Azure.Management.ResourceManager.Version2021_01_01.Models; using Microsoft.Azure.ServiceManagement.Common.Models; using Microsoft.Rest.Azure; using Microsoft.WindowsAzure.Commands.Common.Test.Mocks; @@ -31,7 +32,7 @@ namespace Microsoft.Azure.Commands.ResourceManager.Common.Test { - public class SubscriptionClientSwitchTest + public class SubscriptionClientSwitchTest : IDisposable { private const string DefaultAccount = "admin@contoso.com"; private static Guid DefaultSubscription = Guid.NewGuid(); @@ -59,6 +60,11 @@ public SubscriptionClientSwitchTest(ITestOutputHelper output) }; } + public void Dispose() + { + SubscritpionClientCandidates.Reset(); + } + private RMProfileClient GetProfileClient() { var sub = new AzureSubscription() @@ -88,8 +94,8 @@ public void SubscriptionClientListTenantFallback() subscriptionList.Enqueue(firstList); var clientFactory = new MockSubscriptionClientFactory(tenants, subscriptionList); - MockSubscriptionClientFactory.TenantListQueueVer2019 = new Queue>>>(); - MockSubscriptionClientFactory.TenantListQueueVer2019.Enqueue(() => + MockSubscriptionClientFactory.TenantListQueueVerLatest = new Queue>>>(); + MockSubscriptionClientFactory.TenantListQueueVerLatest.Enqueue(() => { var e = new CloudException("The api-version is invalid. The supported versions are '2018-09-01,2018-08-01,2018-07-01,2018-06-01,2018-05-01,2018-02-01,2018-01-01,2017-12-01,2017-08-01,2017-06-01,2017-05-10,2017-05-01,2017-03-01,2016-09-01,2016-07-01,2016-06-01,2016-02-01,2015-11-01,2015-01-01,2014-04-01-preview,2014-04-01,2014-01-01,2013-03-01,2014-02-26,2014-04'."); e.Body = new CloudError(); @@ -97,12 +103,12 @@ public void SubscriptionClientListTenantFallback() throw e; }); - clientFactory.ListTenantQueueDequeueVer2019 = () => + clientFactory.ListTenantQueueDequeueVerLatest = () => { AzureOperationResponse> result = null; try { - result = MockSubscriptionClientFactory.TenantListQueueVer2019.Dequeue().Invoke(); + result = MockSubscriptionClientFactory.TenantListQueueVerLatest.Dequeue().Invoke(); } catch (CloudException e) { @@ -116,7 +122,7 @@ public void SubscriptionClientListTenantFallback() }; subscriptionClients.Clear(); - subscriptionClients.Enqueue(clientFactory.GetSubscriptionClientVer2019()); + subscriptionClients.Enqueue(clientFactory.GetSubscriptionClientVerLatest()); subscriptionClients.Enqueue(clientFactory.GetSubscriptionClientVer2016()); var mock = new AccountMockClientFactory(() => @@ -152,8 +158,8 @@ public void SubscriptionClientGetSubFallback() subscriptionList.Enqueue(firstList); var clientFactory = new MockSubscriptionClientFactory(tenants, subscriptionList); - MockSubscriptionClientFactory.SubGetQueueVer2019 = new Queue>>(); - MockSubscriptionClientFactory.SubGetQueueVer2019.Enqueue(() => + MockSubscriptionClientFactory.SubGetQueueVerLatest = new Queue>>(); + MockSubscriptionClientFactory.SubGetQueueVerLatest.Enqueue(() => { var e = new CloudException("The api-version is invalid. The supported versions are '2018-09-01,2018-08-01,2018-07-01,2018-06-01,2018-05-01,2018-02-01,2018-01-01,2017-12-01,2017-08-01,2017-06-01,2017-05-10,2017-05-01,2017-03-01,2016-09-01,2016-07-01,2016-06-01,2016-02-01,2015-11-01,2015-01-01,2014-04-01-preview,2014-04-01,2014-01-01,2013-03-01,2014-02-26,2014-04'."); e.Body = new CloudError(); @@ -161,12 +167,12 @@ public void SubscriptionClientGetSubFallback() throw e; }); - clientFactory.GetSubQueueDequeueVer2019 = () => + clientFactory.GetSubQueueDequeueVerLatest = () => { AzureOperationResponse result = null; try { - result = MockSubscriptionClientFactory.SubGetQueueVer2019.Dequeue().Invoke(); + result = MockSubscriptionClientFactory.SubGetQueueVerLatest.Dequeue().Invoke(); } catch (CloudException e) { @@ -180,7 +186,7 @@ public void SubscriptionClientGetSubFallback() }; subscriptionClients.Clear(); - subscriptionClients.Enqueue(clientFactory.GetSubscriptionClientVer2019()); + subscriptionClients.Enqueue(clientFactory.GetSubscriptionClientVerLatest()); subscriptionClients.Enqueue(clientFactory.GetSubscriptionClientVer2016()); var mock = new AccountMockClientFactory(() => @@ -218,8 +224,8 @@ public void SubscriptionClientListSubFallback() subscriptionList.Enqueue(secondList); var clientFactory = new MockSubscriptionClientFactory(tenants, subscriptionList); - MockSubscriptionClientFactory.SubListQueueVer2019 = new Queue>>>(); - MockSubscriptionClientFactory.SubListQueueVer2019.Enqueue(() => + MockSubscriptionClientFactory.SubListQueueVerLatest = new Queue>>>(); + MockSubscriptionClientFactory.SubListQueueVerLatest.Enqueue(() => { var e = new CloudException("The api-version is invalid. The supported versions are '2018-09-01,2018-08-01,2018-07-01,2018-06-01,2018-05-01,2018-02-01,2018-01-01,2017-12-01,2017-08-01,2017-06-01,2017-05-10,2017-05-01,2017-03-01,2016-09-01,2016-07-01,2016-06-01,2016-02-01,2015-11-01,2015-01-01,2014-04-01-preview,2014-04-01,2014-01-01,2013-03-01,2014-02-26,2014-04'."); e.Body = new CloudError(); @@ -227,12 +233,12 @@ public void SubscriptionClientListSubFallback() throw e; }); - clientFactory.ListSubQueueDequeueVer2019 = () => + clientFactory.ListSubQueueDequeueVerLatest = () => { AzureOperationResponse> result = null; try { - result = MockSubscriptionClientFactory.SubListQueueVer2019.Dequeue().Invoke(); + result = MockSubscriptionClientFactory.SubListQueueVerLatest.Dequeue().Invoke(); } catch (CloudException e) { @@ -246,7 +252,7 @@ public void SubscriptionClientListSubFallback() }; subscriptionClients.Clear(); - subscriptionClients.Enqueue(clientFactory.GetSubscriptionClientVer2019()); + subscriptionClients.Enqueue(clientFactory.GetSubscriptionClientVerLatest()); subscriptionClients.Enqueue(clientFactory.GetSubscriptionClientVer2016()); var mock = new AccountMockClientFactory(() => diff --git a/src/Accounts/Accounts.Test/SubscriptionCmdletTests.cs b/src/Accounts/Accounts.Test/SubscriptionCmdletTests.cs index dbc3066028e9..729c41fa2a95 100644 --- a/src/Accounts/Accounts.Test/SubscriptionCmdletTests.cs +++ b/src/Accounts/Accounts.Test/SubscriptionCmdletTests.cs @@ -52,5 +52,12 @@ public void SetAzureRmContextWithoutSubscription() { TestRunner.RunTestScript("Test-SetAzureRmContextWithoutSubscription"); } + + [Fact] + [Trait(Category.AcceptanceType, Category.CheckIn)] + public void GetSubscriptionsWithTags() + { + TestRunner.RunTestScript("Test-GetSubscriptionsWithTags"); + } } } diff --git a/src/Accounts/Accounts.Test/SubscriptionCmdletTests.ps1 b/src/Accounts/Accounts.Test/SubscriptionCmdletTests.ps1 index a087b318d01a..fc897e20666c 100644 --- a/src/Accounts/Accounts.Test/SubscriptionCmdletTests.ps1 +++ b/src/Accounts/Accounts.Test/SubscriptionCmdletTests.ps1 @@ -120,4 +120,16 @@ function Test-SetAzureRmContextWithoutSubscription Assert-True { $context.Tenant -ne $null } Assert-AreEqual $context.Tenant.Id $firstSubscription.HomeTenantId Assert-AreEqual $context.Subscription.Id $firstSubscription.Id -} \ No newline at end of file +} + +<# +.SYNOPSIS +Check whether tags works with subscripiton +.DESCRIPTION +SmokeTest +#> +function Test-GetSubscriptionsWithTags +{ + $allSubscriptions = Get-AzSubscription + Assert-True {($allSubscriptions | Where-Object { $_.Tags -ne $null}).Count -gt 0} +} diff --git a/src/Accounts/Accounts.Test/TenantCmdletMockTests.cs b/src/Accounts/Accounts.Test/TenantCmdletMockTests.cs index ac8c5e836270..c85a3f147b08 100644 --- a/src/Accounts/Accounts.Test/TenantCmdletMockTests.cs +++ b/src/Accounts/Accounts.Test/TenantCmdletMockTests.cs @@ -116,7 +116,9 @@ public void GetTenantWithTenantParameter() { { "DisplayName", "Microsoft" }, { "TenantCategory", "Home" }, - { "Domains", "test0.com,test1.com,test2.microsoft.com,test3.microsoft.com" } + { "Domains", "test0.com,test1.com,test2.microsoft.com,test3.microsoft.com" }, + { "TenantType", "AAD"}, + { "DefaultDomain", "test0.com,test1.com" } } }); result.Add(new AzureTenant() @@ -142,6 +144,8 @@ public void GetTenantWithTenantParameter() Assert.Equal(cmdlet.TenantId, ((PSAzureTenant)OutputPipeline.First()).Id.ToString()); Assert.Equal("Home", ((PSAzureTenant)OutputPipeline.First()).TenantCategory); Assert.Equal(4, ((PSAzureTenant)OutputPipeline.First()).Domains.Length); + Assert.Equal("AAD", ((PSAzureTenant)OutputPipeline.First()).TenantType); + Assert.Equal("test0.com,test1.com", ((PSAzureTenant)OutputPipeline.First()).DefaultDomain); } [Fact] @@ -162,7 +166,8 @@ public void GetTenantWithDomainParameter() { { "DisplayName", "Microsoft" }, { "TenantCategory", "Home" }, - { "Domains", "test0.com,test1.com,test2.microsoft.com," + cmdlet.TenantId } + { "Domains", "test0.com,test1.com,test2.microsoft.com," + cmdlet.TenantId }, + { "TenantBrandingLogoUrl", "https://secure.fakesite.com/xxxxx-yyyy/logintenantbranding/0/bannerlogo?ts=0000000000" } } }); result.Add(new AzureTenant() @@ -190,6 +195,7 @@ public void GetTenantWithDomainParameter() var domains = ((PSAzureTenant)OutputPipeline.First()).Domains; Assert.Equal(4, domains.Length); Assert.True(Array.Exists(domains, t => t.Equals(cmdlet.TenantId, StringComparison.OrdinalIgnoreCase))); + Assert.Equal("https://secure.fakesite.com/xxxxx-yyyy/logintenantbranding/0/bannerlogo?ts=0000000000", ((PSAzureTenant)OutputPipeline.First()).TenantBrandingLogoUrl); } [Fact] @@ -219,7 +225,8 @@ public void GetTenantWithoutParameters() { { "DisplayName", "Macrohard" }, { "TenantCategory", "Home" }, - { "Domains", "test.macrohard.com" } + { "Domains", "test.macrohard.com" }, + { "CountryCode", "US" } } }); return result; @@ -242,6 +249,7 @@ public void GetTenantWithoutParameters() Assert.Equal(defaultContext.Tenant.Id, tenantB.Id.ToString()); Assert.Equal("Home", tenantB.TenantCategory); Assert.Single(tenantB.Domains); + Assert.Equal("US", tenantB.CountryCode); } } } diff --git a/src/Accounts/Accounts/ChangeLog.md b/src/Accounts/Accounts/ChangeLog.md index 97791e504e7e..237218f0bfde 100644 --- a/src/Accounts/Accounts/ChangeLog.md +++ b/src/Accounts/Accounts/ChangeLog.md @@ -19,6 +19,8 @@ --> ## Upcoming Release +* Added Tags, AuthorizationSource to PSAzureSusbscripiton and added TenantType, DefaultDomain, TenantBrandingLogoUrl, CountryCode to PSAzureTenant +* Upgraded subscription client to 2021-01-01 * Removed Interactive mode check in common lib * Added endpoint of OperationalInsights to environment AzureChinaCloud [#15305] * Printed auto generated modules' default logs to verbose stream diff --git a/src/Accounts/Accounts/Models/SubscriptionClientProxy.cs b/src/Accounts/Accounts/Models/SubscriptionClientProxy.cs index df0c9eb6061e..1f32028530e1 100644 --- a/src/Accounts/Accounts/Models/SubscriptionClientProxy.cs +++ b/src/Accounts/Accounts/Models/SubscriptionClientProxy.cs @@ -20,7 +20,7 @@ using System.Collections.Concurrent; using System.Threading; using SubscriptionClientVersion2016 = Microsoft.Azure.Commands.ResourceManager.Common.Utilities.SubscriptionClientWrapper; -using SubscriptionClientVersion2019 = Microsoft.Azure.Commands.ResourceManager.Common.Utilities.Version2019_06_01.SubscriptionClientWrapper; +using SubscriptionClientVersion2021 = Microsoft.Azure.Commands.ResourceManager.Common.Utilities.Version2021_01_01.SubscriptionClientWrapper; namespace Microsoft.Azure.Commands.Profile.Models { @@ -63,7 +63,7 @@ static public SubscritpionClientCandidates Instance private SubscritpionClientCandidates() { - Enqueue(new SubscriptionClientVersion2019()); + Enqueue(new SubscriptionClientVersion2021()); Enqueue(new SubscriptionClientVersion2016()); } diff --git a/src/Accounts/Accounts/Models/Version2016_06_01/SubscriptionClientWrapper.cs b/src/Accounts/Accounts/Models/Version2016_06_01/SubscriptionClientWrapper.cs index 891150d07773..bbb32a4e2d4b 100644 --- a/src/Accounts/Accounts/Models/Version2016_06_01/SubscriptionClientWrapper.cs +++ b/src/Accounts/Accounts/Models/Version2016_06_01/SubscriptionClientWrapper.cs @@ -15,7 +15,6 @@ using Microsoft.Azure.Commands.Common.Authentication; using Microsoft.Azure.Commands.Common.Authentication.Abstractions; using Microsoft.Azure.Commands.ResourceManager.Common.Paging; -using Microsoft.Azure.Commands.ResourceManager.Version2019_06_01.Customized; using Microsoft.Azure.Internal.Subscriptions; using Microsoft.Azure.Internal.Subscriptions.Models; using Microsoft.Azure.Internal.Subscriptions.Models.Utilities; diff --git a/src/Accounts/Accounts/Models/Version2019_06_01/SubscriptionClientWrapper.cs b/src/Accounts/Accounts/Models/Version2021_01_01/SubscriptionClientWrapper.cs similarity index 93% rename from src/Accounts/Accounts/Models/Version2019_06_01/SubscriptionClientWrapper.cs rename to src/Accounts/Accounts/Models/Version2021_01_01/SubscriptionClientWrapper.cs index 1179c72338c8..405a75b0c54f 100644 --- a/src/Accounts/Accounts/Models/Version2019_06_01/SubscriptionClientWrapper.cs +++ b/src/Accounts/Accounts/Models/Version2021_01_01/SubscriptionClientWrapper.cs @@ -15,22 +15,22 @@ using Microsoft.Azure.Commands.Common.Authentication; using Microsoft.Azure.Commands.Common.Authentication.Abstractions; using Microsoft.Azure.Commands.ResourceManager.Common.Paging; -using Microsoft.Azure.Commands.ResourceManager.Version2019_06_01.Customized; -using Microsoft.Azure.Management.ResourceManager.Version2019_06_01; -using Microsoft.Azure.Management.ResourceManager.Version2019_06_01.Models; -using Microsoft.Azure.Management.ResourceManager.Version2019_06_01.Models.Utilities; +using Microsoft.Azure.Commands.ResourceManager.Version2021_01_01.Utilities; +using Microsoft.Azure.Management.ResourceManager.Version2021_01_01; +using Microsoft.Azure.Management.ResourceManager.Version2021_01_01.Models; +using Microsoft.Azure.Management.ResourceManager.Version2021_01_01.Models.Utilities; using Microsoft.Rest; using Microsoft.WindowsAzure.Commands.Utilities.Common; using System.Collections.Generic; using System.Linq; -namespace Microsoft.Azure.Commands.ResourceManager.Common.Utilities.Version2019_06_01 +namespace Microsoft.Azure.Commands.ResourceManager.Common.Utilities.Version2021_01_01 { internal class SubscriptionClientWrapper : ISubscriptionClientWrapper { public SubscriptionClientWrapper() { - ApiVersion = "2019-06-01"; + ApiVersion = "2021-01-01"; } public IList ListAccountTenants(IAccessToken accessToken, IAzureEnvironment environment) diff --git a/src/Accounts/Authentication.ResourceManager/Models/PSAzureSubscription.cs b/src/Accounts/Authentication.ResourceManager/Models/PSAzureSubscription.cs index 15112885f7a3..e1aae1142462 100644 --- a/src/Accounts/Authentication.ResourceManager/Models/PSAzureSubscription.cs +++ b/src/Accounts/Authentication.ResourceManager/Models/PSAzureSubscription.cs @@ -210,5 +210,21 @@ public static string GetAccountName(string connectionString) return result; } + + public string AuthorizationSource + { + get + { + return this.GetProperty(AzureSubscription.Property.AuthorizationSource); + } + } + + public Dictionary Tags + { + get + { + return this.GetTags(); + } + } } } diff --git a/src/Accounts/Authentication.ResourceManager/Models/PSAzureTenant.cs b/src/Accounts/Authentication.ResourceManager/Models/PSAzureTenant.cs index 5b709cbb846b..4607de250bd6 100644 --- a/src/Accounts/Authentication.ResourceManager/Models/PSAzureTenant.cs +++ b/src/Accounts/Authentication.ResourceManager/Models/PSAzureTenant.cs @@ -106,19 +106,27 @@ public override string ToString() return this.Id; } - public string[] Domains + public string TenantCategory { get { - return this.GetPropertyAsArray(AzureTenant.Property.Domains); + return this.GetProperty(AzureTenant.Property.TenantCategory); } } - public string TenantCategory + public string Country { get { - return this.GetProperty(AzureTenant.Property.TenantCategory); + return this.GetProperty(AzureTenant.Property.Country); + } + } + + public string CountryCode + { + get + { + return this.GetProperty(AzureTenant.Property.CountryCode); } } @@ -129,5 +137,36 @@ public string Name return this.GetProperty(AzureTenant.Property.DisplayName); } } + + public string[] Domains + { + get + { + return this.GetPropertyAsArray(AzureTenant.Property.Domains); + } + } + public string DefaultDomain + { + get + { + return this.GetProperty(AzureTenant.Property.DefaultDomain); + } + } + + public string TenantType + { + get + { + return this.GetProperty(AzureTenant.Property.TenantType); + } + } + + public string TenantBrandingLogoUrl + { + get + { + return this.GetProperty(AzureTenant.Property.TenantBrandingLogoUrl); + } + } } } diff --git a/src/Accounts/Authentication.Test/Cmdlets/ConnectAccount.cs b/src/Accounts/Authentication.Test/Cmdlets/ConnectAccount.cs index 978a42435fbd..cff2ddd3c76d 100644 --- a/src/Accounts/Authentication.Test/Cmdlets/ConnectAccount.cs +++ b/src/Accounts/Authentication.Test/Cmdlets/ConnectAccount.cs @@ -18,10 +18,10 @@ using Microsoft.Azure.Commands.Common.Authentication.Models; using Microsoft.Azure.Commands.Common.Authentication.ResourceManager; using Microsoft.Azure.Commands.ResourceManager.Common; -using Microsoft.Azure.Commands.ResourceManager.Version2019_06_01.Customized; -using Microsoft.Azure.Management.ResourceManager.Version2019_06_01; -using Microsoft.Azure.Management.ResourceManager.Version2019_06_01.Models; -using Microsoft.Azure.Management.ResourceManager.Version2019_06_01.Models.Utilities; +using Microsoft.Azure.Commands.ResourceManager.Version2021_01_01.Utilities; +using Microsoft.Azure.Management.ResourceManager.Version2021_01_01; +using Microsoft.Azure.Management.ResourceManager.Version2021_01_01.Models; +using Microsoft.Azure.Management.ResourceManager.Version2021_01_01.Models.Utilities; using Microsoft.Rest; using Microsoft.WindowsAzure.Commands.Utilities.Common; using System; diff --git a/src/Resources/Resources.Test/ScenarioTests/ResourcesController.cs b/src/Resources/Resources.Test/ScenarioTests/ResourcesController.cs index 9f03c47f47b2..82dab68d5e57 100644 --- a/src/Resources/Resources.Test/ScenarioTests/ResourcesController.cs +++ b/src/Resources/Resources.Test/ScenarioTests/ResourcesController.cs @@ -53,7 +53,7 @@ public sealed class ResourcesController public FeatureClient FeatureClient { get; private set; } - public Management.ResourceManager.Version2019_06_01.SubscriptionClient SubscriptionClient { get; private set; } + public Management.ResourceManager.Version2021_01_01.SubscriptionClient SubscriptionClient { get; private set; } public AuthorizationManagementClient AuthorizationManagementClient { get; private set; } @@ -220,9 +220,9 @@ private static DeploymentScriptsClient GetDeploymentScriptsClient(MockContext co return context.GetServiceClient(TestEnvironmentFactory.GetTestEnvironment()); } - private static Management.ResourceManager.Version2019_06_01.SubscriptionClient GetSubscriptionClient(MockContext context) + private static Management.ResourceManager.Version2021_01_01.SubscriptionClient GetSubscriptionClient(MockContext context) { - return context.GetServiceClient(TestEnvironmentFactory.GetTestEnvironment()); + return context.GetServiceClient(TestEnvironmentFactory.GetTestEnvironment()); } private static ManagementGroupsAPIClient GetManagementGroupsApiClient(MockContext context) diff --git a/src/StorageSync/StorageSync.Test/TestController.cs b/src/StorageSync/StorageSync.Test/TestController.cs index 447682d31c18..cd9996edfd05 100644 --- a/src/StorageSync/StorageSync.Test/TestController.cs +++ b/src/StorageSync/StorageSync.Test/TestController.cs @@ -19,7 +19,7 @@ using Microsoft.Azure.Graph.RBAC.Version1_6_20190326; using Microsoft.Azure.Management.Authorization.Version2015_07_01; using Microsoft.Azure.Management.Internal.Resources; -using Microsoft.Azure.Management.ResourceManager.Version2019_06_01; +using Microsoft.Azure.Management.ResourceManager.Version2021_01_01; using Microsoft.Azure.Management.Storage.Version2017_10_01; using Microsoft.Azure.Management.StorageSync; using Microsoft.Azure.ServiceManagement.Common.Models;