Skip to content

Commit 5b0cab4

Browse files
authored
Update subscription client to 2021-01-01 (#15351)
* Update subscription client to 2021-01-01 * Add addtional properties and integrate common lib of 1.3.39 * Fix test case failure of StorageSync and Resources * Reset subscripiton client proxy at then end of subscripition client switch tests
1 parent eb271d8 commit 5b0cab4

File tree

18 files changed

+324
-101
lines changed

18 files changed

+324
-101
lines changed

src/Accounts/Accounts.Test/AzureRMProfileTests.cs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
using Microsoft.Azure.Commands.Profile.Models;
2121
using Microsoft.Azure.Commands.Profile.Test;
2222
using Microsoft.Azure.Commands.ScenarioTest;
23-
using Microsoft.Azure.Management.ResourceManager.Version2019_06_01.Models;
23+
using Microsoft.Azure.Management.ResourceManager.Version2021_01_01.Models;
2424
using Microsoft.Azure.ServiceManagement.Common.Models;
2525
using Microsoft.Rest;
2626
using Microsoft.Rest.Azure;
@@ -62,7 +62,7 @@ private static RMProfileClient SetupTestEnvironment(List<string> tenants, params
6262
var clientFactory = new MockSubscriptionClientFactory(tenants, subscriptionList);
6363
var mock = new MockClientFactory(new List<object>
6464
{
65-
clientFactory.GetSubscriptionClientVer2019(),
65+
clientFactory.GetSubscriptionClientVerLatest(),
6666
clientFactory.GetSubscriptionClientVer2016()
6767
}, true);
6868
mock.MoqClients = true;
@@ -90,7 +90,7 @@ private static AzureRmProfile SetupLogin(List<string> tenants, params List<strin
9090
var clientFactory = new MockSubscriptionClientFactory(tenants, subscriptionList);
9191
var mock = new MockClientFactory(new List<object>
9292
{
93-
clientFactory.GetSubscriptionClientVer2019(),
93+
clientFactory.GetSubscriptionClientVerLatest(),
9494
clientFactory.GetSubscriptionClientVer2016()
9595
}, true);
9696
mock.MoqClients = true;
@@ -144,7 +144,7 @@ public void SpecifyTenantAndSubscriptionIdSucceed()
144144
null,
145145
false,
146146
null);
147-
Assert.Equal("2019-06-01", client.SubscriptionAndTenantClient.ApiVersion);
147+
Assert.Equal("2021-01-01", client.SubscriptionAndTenantClient.ApiVersion);
148148
}
149149

150150
[Fact]
@@ -164,8 +164,8 @@ public void SubscriptionIdNotExist()
164164
TenantId = DefaultTenant.ToString()
165165
};
166166

167-
MockSubscriptionClientFactory.SubGetQueueVer2019 = new Queue<Func<AzureOperationResponse<Subscription>>>();
168-
MockSubscriptionClientFactory.SubGetQueueVer2019.Enqueue(() =>
167+
MockSubscriptionClientFactory.SubGetQueueVerLatest = new Queue<Func<AzureOperationResponse<Subscription>>>();
168+
MockSubscriptionClientFactory.SubGetQueueVerLatest.Enqueue(() =>
169169
{
170170
throw new CloudException("InvalidAuthenticationTokenTenant: The access token is from the wrong issuer");
171171
});
@@ -179,7 +179,7 @@ public void SubscriptionIdNotExist()
179179
null,
180180
false,
181181
null));
182-
Assert.Equal("2019-06-01", client.SubscriptionAndTenantClient.ApiVersion);
182+
Assert.Equal("2021-01-01", client.SubscriptionAndTenantClient.ApiVersion);
183183
}
184184

185185
[Fact]
@@ -230,8 +230,8 @@ public void SubscriptionIdNotInFirstTenant()
230230
TenantId = DefaultTenant.ToString()
231231
};
232232

233-
MockSubscriptionClientFactory.SubGetQueueVer2019 = new Queue<Func<AzureOperationResponse<Subscription>>>();
234-
MockSubscriptionClientFactory.SubGetQueueVer2019.Enqueue(() =>
233+
MockSubscriptionClientFactory.SubGetQueueVerLatest = new Queue<Func<AzureOperationResponse<Subscription>>>();
234+
MockSubscriptionClientFactory.SubGetQueueVerLatest.Enqueue(() =>
235235
{
236236
throw new CloudException("InvalidAuthenticationTokenTenant: The access token is from the wrong issuer");
237237
});
@@ -266,8 +266,8 @@ public void SubscriptionNameNotInFirstTenant()
266266
TenantId = DefaultTenant.ToString()
267267
};
268268

269-
MockSubscriptionClientFactory.SubListQueueVer2019 = new Queue<Func<AzureOperationResponse<IPage<Subscription>>>>();
270-
MockSubscriptionClientFactory.SubListQueueVer2019.Enqueue(() =>
269+
MockSubscriptionClientFactory.SubListQueueVerLatest = new Queue<Func<AzureOperationResponse<IPage<Subscription>>>>();
270+
MockSubscriptionClientFactory.SubListQueueVerLatest.Enqueue(() =>
271271
{
272272
var sub1 = new Subscription(
273273
id: DefaultSubscription.ToString(),

src/Accounts/Accounts.Test/AzureRMProfileTestsForMultitenant.cs

Lines changed: 30 additions & 24 deletions
Large diffs are not rendered by default.

src/Accounts/Accounts.Test/Mocks/MockSubscriptionClientFactory.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15-
using Microsoft.Azure.Management.ResourceManager.Version2019_06_01;
16-
using Microsoft.Azure.Management.ResourceManager.Version2019_06_01.Models;
15+
using Microsoft.Azure.Management.ResourceManager.Version2021_01_01;
16+
using Microsoft.Azure.Management.ResourceManager.Version2021_01_01.Models;
1717
using Microsoft.Rest.Azure;
1818
using Moq;
1919
using System;

src/Accounts/Accounts.Test/Mocks/MockSubscriptionClientFactoryVersion2019.cs

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15-
using Microsoft.Azure.Management.ResourceManager.Version2019_06_01;
16-
using Microsoft.Azure.Management.ResourceManager.Version2019_06_01.Models;
15+
using Microsoft.Azure.Management.ResourceManager.Version2021_01_01;
16+
using Microsoft.Azure.Management.ResourceManager.Version2021_01_01.Models;
1717
using Microsoft.Rest.Azure;
1818
using Moq;
1919
using System;
@@ -29,24 +29,24 @@ namespace Microsoft.Azure.Commands.ResourceManager.Common.Test
2929
{
3030
public partial class MockSubscriptionClientFactory
3131
{
32-
public static Queue<Func<AzureOperationResponse<Subscription>>> SubGetQueueVer2019 { get; set; } = null;
33-
public static Queue<Func<AzureOperationResponse<IPage<Subscription>>>> SubListQueueVer2019 { get; set; } = null;
34-
public static Queue<Func<AzureOperationResponse<IPage<TenantIdDescription>>>> TenantListQueueVer2019 { get; set; } = null;
32+
public static Queue<Func<AzureOperationResponse<Subscription>>> SubGetQueueVerLatest { get; set; } = null;
33+
public static Queue<Func<AzureOperationResponse<IPage<Subscription>>>> SubListQueueVerLatest { get; set; } = null;
34+
public static Queue<Func<AzureOperationResponse<IPage<TenantIdDescription>>>> TenantListQueueVerLatest { get; set; } = null;
3535

36-
public DeGetAsyncQueue<Subscription> GetSubQueueDequeueVer2019 = () => Task.FromResult(SubGetQueueVer2019.Dequeue().Invoke());
37-
public DeListAsyncQueue<Subscription> ListSubQueueDequeueVer2019 = () => Task.FromResult(SubListQueueVer2019.Dequeue().Invoke());
38-
public DeListAsyncQueue<TenantIdDescription> ListTenantQueueDequeueVer2019 = () => Task.FromResult(TenantListQueueVer2019.Dequeue().Invoke());
36+
public DeGetAsyncQueue<Subscription> GetSubQueueDequeueVerLatest = () => Task.FromResult(SubGetQueueVerLatest.Dequeue().Invoke());
37+
public DeListAsyncQueue<Subscription> ListSubQueueDequeueVerLatest = () => Task.FromResult(SubListQueueVerLatest.Dequeue().Invoke());
38+
public DeListAsyncQueue<TenantIdDescription> ListTenantQueueDequeueVerLatest = () => Task.FromResult(TenantListQueueVerLatest.Dequeue().Invoke());
3939

40-
public SubscriptionClient GetSubscriptionClientVer2019()
40+
public SubscriptionClient GetSubscriptionClientVerLatest()
4141
{
4242
var tenantMock = new Mock<ITenantsOperations>();
4343
tenantMock.Setup(t => t.ListWithHttpMessagesAsync(It.IsAny<Dictionary<string, List<string>>>(), It.IsAny<CancellationToken>()))
4444
.Returns(
4545
(Dictionary<string, List<string>> ch, CancellationToken token) =>
4646
{
47-
if(TenantListQueueVer2019 != null && TenantListQueueVer2019.Any())
47+
if(TenantListQueueVerLatest != null && TenantListQueueVerLatest.Any())
4848
{
49-
return ListTenantQueueDequeueVer2019();
49+
return ListTenantQueueDequeueVerLatest();
5050
}
5151
var tenants = _tenants.Select((k) => new TenantIdDescription(id: k, tenantId: k));
5252
var mockPage = new MockPage<TenantIdDescription>(tenants.ToList());
@@ -64,9 +64,9 @@ public SubscriptionClient GetSubscriptionClientVer2019()
6464
s => s.GetWithHttpMessagesAsync(It.IsAny<string>(), It.IsAny<Dictionary<string, List<string>>>(), It.IsAny<CancellationToken>())).Returns(
6565
(string subId, Dictionary<string, List<string>> ch, CancellationToken token) =>
6666
{
67-
if (SubGetQueueVer2019 != null && SubGetQueueVer2019.Any())
67+
if (SubGetQueueVerLatest != null && SubGetQueueVerLatest.Any())
6868
{
69-
return GetSubQueueDequeueVer2019();
69+
return GetSubQueueDequeueVerLatest();
7070
}
7171
AzureOperationResponse<Subscription> result = new AzureOperationResponse<Subscription>
7272
{
@@ -91,9 +91,9 @@ public SubscriptionClient GetSubscriptionClientVer2019()
9191
(s) => s.ListWithHttpMessagesAsync(null, It.IsAny<CancellationToken>())).Returns(
9292
(Dictionary<string, List<string>> ch, CancellationToken token) =>
9393
{
94-
if (SubListQueueVer2019 != null && SubListQueueVer2019.Any())
94+
if (SubListQueueVerLatest != null && SubListQueueVerLatest.Any())
9595
{
96-
return ListSubQueueDequeueVer2019();
96+
return ListSubQueueDequeueVerLatest();
9797
}
9898

9999
AzureOperationResponse<IPage<Subscription>> result = null;
@@ -160,9 +160,9 @@ private ITenantsOperations GetTenantMock(List<TenantIdDescription> tenants)
160160
.Returns(
161161
(Dictionary<string, List<string>> ch, CancellationToken token) =>
162162
{
163-
if (TenantListQueueVer2019 != null && TenantListQueueVer2019.Any())
163+
if (TenantListQueueVerLatest != null && TenantListQueueVerLatest.Any())
164164
{
165-
return ListTenantQueueDequeueVer2019();
165+
return ListTenantQueueDequeueVerLatest();
166166
}
167167
var mockPage = new MockPage<TenantIdDescription>(tenants);
168168

@@ -190,9 +190,9 @@ private ISubscriptionsOperations GetSubscriptionMock(List<Subscription> subscrip
190190
s => s.GetWithHttpMessagesAsync(It.IsAny<string>(), It.IsAny<Dictionary<string, List<string>>>(), It.IsAny<CancellationToken>())).Returns(
191191
(string subId, Dictionary<string, List<string>> ch, CancellationToken token) =>
192192
{
193-
if (SubGetQueueVer2019 != null && SubGetQueueVer2019.Any())
193+
if (SubGetQueueVerLatest != null && SubGetQueueVerLatest.Any())
194194
{
195-
return GetSubQueueDequeueVer2019();
195+
return GetSubQueueDequeueVerLatest();
196196
}
197197
AzureOperationResponse<Subscription> result = new AzureOperationResponse<Subscription>()
198198
{
@@ -210,9 +210,9 @@ private ISubscriptionsOperations GetSubscriptionMock(List<Subscription> subscrip
210210
(s) => s.ListWithHttpMessagesAsync(null, It.IsAny<CancellationToken>())).Returns(
211211
(Dictionary<string, List<string>> ch, CancellationToken token) =>
212212
{
213-
if (SubListQueueVer2019 != null && SubListQueueVer2019.Any())
213+
if (SubListQueueVerLatest != null && SubListQueueVerLatest.Any())
214214
{
215-
return ListSubQueueDequeueVer2019();
215+
return ListSubQueueDequeueVerLatest();
216216
}
217217

218218
AzureOperationResponse<IPage<Subscription>> result = null;
@@ -249,7 +249,7 @@ private ISubscriptionsOperations GetSubscriptionMock(List<Subscription> subscrip
249249
return subscriptionMock.Object;
250250
}
251251

252-
public SubscriptionClient GetSubscriptionClientVer2019(List<TenantIdDescription> tenants, List<Subscription> subscriptionGetList, List<List<Subscription>> subscriptionListLists, List<bool> HasNextPage = null)
252+
public SubscriptionClient GetSubscriptionClientVerLatest(List<TenantIdDescription> tenants, List<Subscription> subscriptionGetList, List<List<Subscription>> subscriptionListLists, List<bool> HasNextPage = null)
253253
{
254254
var client = new Mock<SubscriptionClient>() { CallBase = true };
255255
if (subscriptionGetList != null || subscriptionListLists != null)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
{
2+
"Entries": [
3+
{
4+
"RequestUri": "/tenants?api-version=2021-01-01",
5+
"EncodedRequestUri": "L3RlbmFudHM/YXBpLXZlcnNpb249MjAyMS0wMS0wMQ==",
6+
"RequestMethod": "GET",
7+
"RequestBody": "",
8+
"RequestHeaders": {
9+
"x-ms-client-request-id": [
10+
"27447c0a-62f3-4ec5-a2ee-46d57196a6c5"
11+
],
12+
"Accept-Language": [
13+
"en-US"
14+
],
15+
"User-Agent": [
16+
"FxVersion/4.6.30015.01",
17+
"OSName/Windows",
18+
"OSVersion/Microsoft.Windows.10.0.19043.",
19+
"Microsoft.Azure.Management.ResourceManager.Version2021.01.01.SubscriptionClient/1.0.0.0"
20+
]
21+
},
22+
"ResponseHeaders": {
23+
"Cache-Control": [
24+
"no-cache"
25+
],
26+
"Pragma": [
27+
"no-cache"
28+
],
29+
"x-ms-ratelimit-remaining-tenant-reads": [
30+
"11999"
31+
],
32+
"x-ms-request-id": [
33+
"aa195b95-77d4-41fe-81ae-041fde762974"
34+
],
35+
"x-ms-correlation-request-id": [
36+
"aa195b95-77d4-41fe-81ae-041fde762974"
37+
],
38+
"x-ms-routing-request-id": [
39+
"SOUTHEASTASIA:20210628T075523Z:aa195b95-77d4-41fe-81ae-041fde762974"
40+
],
41+
"Strict-Transport-Security": [
42+
"max-age=31536000; includeSubDomains"
43+
],
44+
"X-Content-Type-Options": [
45+
"nosniff"
46+
],
47+
"Date": [
48+
"Mon, 28 Jun 2021 07:55:23 GMT"
49+
],
50+
"Content-Type": [
51+
"application/json; charset=utf-8"
52+
],
53+
"Expires": [
54+
"-1"
55+
],
56+
"Content-Length": [
57+
"140"
58+
]
59+
},
60+
"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}",
61+
"StatusCode": 200
62+
},
63+
{
64+
"RequestUri": "/subscriptions?api-version=2021-01-01",
65+
"EncodedRequestUri": "L3N1YnNjcmlwdGlvbnM/YXBpLXZlcnNpb249MjAyMS0wMS0wMQ==",
66+
"RequestMethod": "GET",
67+
"RequestBody": "",
68+
"RequestHeaders": {
69+
"x-ms-client-request-id": [
70+
"27447c0a-62f3-4ec5-a2ee-46d57196a6c5"
71+
],
72+
"Accept-Language": [
73+
"en-US"
74+
],
75+
"User-Agent": [
76+
"FxVersion/4.6.30015.01",
77+
"OSName/Windows",
78+
"OSVersion/Microsoft.Windows.10.0.19043.",
79+
"Microsoft.Azure.Management.ResourceManager.Version2021.01.01.SubscriptionClient/1.0.0.0"
80+
]
81+
},
82+
"ResponseHeaders": {
83+
"Cache-Control": [
84+
"no-cache"
85+
],
86+
"Pragma": [
87+
"no-cache"
88+
],
89+
"x-ms-ratelimit-remaining-tenant-reads": [
90+
"11999"
91+
],
92+
"x-ms-request-id": [
93+
"c8cf462f-f2c0-4ef4-8dc3-aee3d36d3293"
94+
],
95+
"x-ms-correlation-request-id": [
96+
"c8cf462f-f2c0-4ef4-8dc3-aee3d36d3293"
97+
],
98+
"x-ms-routing-request-id": [
99+
"SOUTHEASTASIA:20210628T075524Z:c8cf462f-f2c0-4ef4-8dc3-aee3d36d3293"
100+
],
101+
"Strict-Transport-Security": [
102+
"max-age=31536000; includeSubDomains"
103+
],
104+
"X-Content-Type-Options": [
105+
"nosniff"
106+
],
107+
"Date": [
108+
"Mon, 28 Jun 2021 07:55:23 GMT"
109+
],
110+
"Content-Type": [
111+
"application/json; charset=utf-8"
112+
],
113+
"Expires": [
114+
"-1"
115+
],
116+
"Content-Length": [
117+
"522"
118+
]
119+
},
120+
"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}",
121+
"StatusCode": 200
122+
}
123+
],
124+
"Names": {},
125+
"Variables": {
126+
"SubscriptionId": "0b1f6471-1bf0-4dda-aec3-cb9272f09590"
127+
}
128+
}

0 commit comments

Comments
 (0)