From 1bfea57d9358a8b62709fbe983c18ae6cd88bc96 Mon Sep 17 00:00:00 2001 From: Lei Jin Date: Tue, 29 Jun 2021 15:02:54 +0800 Subject: [PATCH] Add addtional properties and integrate common lib of 1.3.39 --- .../Accounts.Test/AzureRMProfileTests.cs | 16 +++---- .../AzureRMProfileTestsForMultitenant.cs | 26 +++++----- ...ockSubscriptionClientFactoryVersion2019.cs | 40 ++++++++-------- .../SubscriptionClientSwitchTest.cs | 30 ++++++------ .../Accounts.Test/TenantCmdletMockTests.cs | 14 ++++-- .../SubscriptionClientWrapper.cs | 0 .../Models/PSAzureSubscription.cs | 8 ++++ .../Models/PSAzureTenant.cs | 47 +++++++++++++++++-- tools/Common.Netcore.Dependencies.targets | 34 +++++++------- 9 files changed, 135 insertions(+), 80 deletions(-) rename src/Accounts/Accounts/Models/{Version2019_06_01 => Version2021_01_01}/SubscriptionClientWrapper.cs (100%) diff --git a/src/Accounts/Accounts.Test/AzureRMProfileTests.cs b/src/Accounts/Accounts.Test/AzureRMProfileTests.cs index 58691a049436..22615f71026e 100644 --- a/src/Accounts/Accounts.Test/AzureRMProfileTests.cs +++ b/src/Accounts/Accounts.Test/AzureRMProfileTests.cs @@ -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; @@ -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"); }); @@ -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 3cc14f878dc2..1a383ec4c9e7 100644 --- a/src/Accounts/Accounts.Test/AzureRMProfileTestsForMultitenant.cs +++ b/src/Accounts/Accounts.Test/AzureRMProfileTestsForMultitenant.cs @@ -276,7 +276,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()) @@ -320,7 +320,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 @@ -364,7 +364,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()) @@ -409,7 +409,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()) @@ -452,7 +452,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 @@ -496,7 +496,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 +537,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 +574,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()) @@ -611,7 +611,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()) @@ -647,7 +647,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()) @@ -683,7 +683,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()) @@ -717,7 +717,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()) @@ -752,7 +752,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/MockSubscriptionClientFactoryVersion2019.cs b/src/Accounts/Accounts.Test/Mocks/MockSubscriptionClientFactoryVersion2019.cs index fc50cc41d353..022fbf706024 100644 --- a/src/Accounts/Accounts.Test/Mocks/MockSubscriptionClientFactoryVersion2019.cs +++ b/src/Accounts/Accounts.Test/Mocks/MockSubscriptionClientFactoryVersion2019.cs @@ -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/SubscriptionClientSwitchTest.cs b/src/Accounts/Accounts.Test/SubscriptionClientSwitchTest.cs index 2428e7258345..3bee188e6826 100644 --- a/src/Accounts/Accounts.Test/SubscriptionClientSwitchTest.cs +++ b/src/Accounts/Accounts.Test/SubscriptionClientSwitchTest.cs @@ -88,8 +88,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 +97,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 +116,7 @@ public void SubscriptionClientListTenantFallback() }; subscriptionClients.Clear(); - subscriptionClients.Enqueue(clientFactory.GetSubscriptionClientVer2019()); + subscriptionClients.Enqueue(clientFactory.GetSubscriptionClientVerLatest()); subscriptionClients.Enqueue(clientFactory.GetSubscriptionClientVer2016()); var mock = new AccountMockClientFactory(() => @@ -152,8 +152,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 +161,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 +180,7 @@ public void SubscriptionClientGetSubFallback() }; subscriptionClients.Clear(); - subscriptionClients.Enqueue(clientFactory.GetSubscriptionClientVer2019()); + subscriptionClients.Enqueue(clientFactory.GetSubscriptionClientVerLatest()); subscriptionClients.Enqueue(clientFactory.GetSubscriptionClientVer2016()); var mock = new AccountMockClientFactory(() => @@ -218,8 +218,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 +227,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 +246,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/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/Models/Version2019_06_01/SubscriptionClientWrapper.cs b/src/Accounts/Accounts/Models/Version2021_01_01/SubscriptionClientWrapper.cs similarity index 100% rename from src/Accounts/Accounts/Models/Version2019_06_01/SubscriptionClientWrapper.cs rename to src/Accounts/Accounts/Models/Version2021_01_01/SubscriptionClientWrapper.cs diff --git a/src/Accounts/Authentication.ResourceManager/Models/PSAzureSubscription.cs b/src/Accounts/Authentication.ResourceManager/Models/PSAzureSubscription.cs index 1d8509d1d942..e1aae1142462 100644 --- a/src/Accounts/Authentication.ResourceManager/Models/PSAzureSubscription.cs +++ b/src/Accounts/Authentication.ResourceManager/Models/PSAzureSubscription.cs @@ -211,6 +211,14 @@ public static string GetAccountName(string connectionString) return result; } + public string AuthorizationSource + { + get + { + return this.GetProperty(AzureSubscription.Property.AuthorizationSource); + } + } + public Dictionary Tags { get 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/tools/Common.Netcore.Dependencies.targets b/tools/Common.Netcore.Dependencies.targets index 2010ef8fdf8f..54a414775fd8 100644 --- a/tools/Common.Netcore.Dependencies.targets +++ b/tools/Common.Netcore.Dependencies.targets @@ -3,22 +3,22 @@ - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + @@ -36,7 +36,7 @@ - $(NugetPackageRoot)\microsoft.azure.powershell.storage\1.3.36-preview\tools\ + $(NugetPackageRoot)\microsoft.azure.powershell.storage\1.3.39-preview\tools\