Skip to content

Commit 3f2656b

Browse files
author
Hovsep Mkrtchyan
committed
Addressing review comments
1 parent ec0eae5 commit 3f2656b

File tree

3 files changed

+131
-29
lines changed

3 files changed

+131
-29
lines changed

src/ResourceManager/Profile/Commands.Profile.Test/SessionRecords/Microsoft.Azure.Commands.Profile.Test.SubscriptionCmdletTests/PipingWithRmContextWorks.json

Lines changed: 124 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,101 @@
11
{
22
"Entries": [
3+
{
4+
"RequestUri": "/subscriptions?api-version=2014-04-01-preview",
5+
"EncodedRequestUri": "L3N1YnNjcmlwdGlvbnM/YXBpLXZlcnNpb249MjAxNC0wNC0wMS1wcmV2aWV3",
6+
"RequestMethod": "GET",
7+
"RequestBody": "",
8+
"RequestHeaders": {
9+
"User-Agent": [
10+
"Microsoft.Azure.Subscriptions.SubscriptionClient/2.0.0.0"
11+
]
12+
},
13+
"ResponseBody": "{\r\n \"value\": [\r\n {\r\n \"id\": \"/subscriptions/00977cdb-163f-435f-9c32-39ec8ae61f4d\",\r\n \"subscriptionId\": \"00977cdb-163f-435f-9c32-39ec8ae61f4d\",\r\n \"displayName\": \"node\",\r\n \"state\": \"Enabled\",\r\n \"subscriptionPolicies\": {\r\n \"locationPlacementId\": \"Internal_2014-09-01\",\r\n \"quotaId\": \"Internal_2014-09-01\"\r\n }\r\n },\r\n {\r\n \"id\": \"/subscriptions/2c224e7e-3ef5-431d-a57b-e71f4662e3a6\",\r\n \"subscriptionId\": \"2c224e7e-3ef5-431d-a57b-e71f4662e3a6\",\r\n \"displayName\": \"Node CLI Test\",\r\n \"state\": \"Enabled\",\r\n \"subscriptionPolicies\": {\r\n \"locationPlacementId\": \"Internal_2014-09-01\",\r\n \"quotaId\": \"Internal_2014-09-01\"\r\n }\r\n },\r\n {\r\n \"id\": \"/subscriptions/6b085460-5f21-477e-ba44-1035046e9101\",\r\n \"subscriptionId\": \"6b085460-5f21-477e-ba44-1035046e9101\",\r\n \"displayName\": \"Azure SDK Infrastructure\",\r\n \"state\": \"Enabled\",\r\n \"subscriptionPolicies\": {\r\n \"locationPlacementId\": \"Internal_2014-09-01\",\r\n \"quotaId\": \"Internal_2014-09-01\"\r\n }\r\n },\r\n {\r\n \"id\": \"/subscriptions/db1ab6f0-4769-4b27-930e-01e2ef9c123c\",\r\n \"subscriptionId\": \"db1ab6f0-4769-4b27-930e-01e2ef9c123c\",\r\n \"displayName\": \"Azure SDK sandbox\",\r\n \"state\": \"Enabled\",\r\n \"subscriptionPolicies\": {\r\n \"locationPlacementId\": \"Internal_2014-09-01\",\r\n \"quotaId\": \"Internal_2014-09-01\"\r\n }\r\n }\r\n ]\r\n}",
14+
"ResponseHeaders": {
15+
"Content-Length": [
16+
"1081"
17+
],
18+
"Content-Type": [
19+
"application/json; charset=utf-8"
20+
],
21+
"Expires": [
22+
"-1"
23+
],
24+
"Pragma": [
25+
"no-cache"
26+
],
27+
"x-ms-ratelimit-remaining-tenant-reads": [
28+
"14999"
29+
],
30+
"x-ms-request-id": [
31+
"ab8756d0-4404-4a60-ae6e-2653656c0b23"
32+
],
33+
"x-ms-correlation-request-id": [
34+
"ab8756d0-4404-4a60-ae6e-2653656c0b23"
35+
],
36+
"x-ms-routing-request-id": [
37+
"WESTUS:20151022T180626Z:ab8756d0-4404-4a60-ae6e-2653656c0b23"
38+
],
39+
"Strict-Transport-Security": [
40+
"max-age=31536000; includeSubDomains"
41+
],
42+
"Cache-Control": [
43+
"no-cache"
44+
],
45+
"Date": [
46+
"Thu, 22 Oct 2015 18:06:26 GMT"
47+
]
48+
},
49+
"StatusCode": 200
50+
},
51+
{
52+
"RequestUri": "/subscriptions?api-version=2014-04-01-preview",
53+
"EncodedRequestUri": "L3N1YnNjcmlwdGlvbnM/YXBpLXZlcnNpb249MjAxNC0wNC0wMS1wcmV2aWV3",
54+
"RequestMethod": "GET",
55+
"RequestBody": "",
56+
"RequestHeaders": {
57+
"User-Agent": [
58+
"Microsoft.Azure.Subscriptions.SubscriptionClient/2.0.0.0"
59+
]
60+
},
61+
"ResponseBody": "{\r\n \"value\": [\r\n {\r\n \"id\": \"/subscriptions/00977cdb-163f-435f-9c32-39ec8ae61f4d\",\r\n \"subscriptionId\": \"00977cdb-163f-435f-9c32-39ec8ae61f4d\",\r\n \"displayName\": \"node\",\r\n \"state\": \"Enabled\",\r\n \"subscriptionPolicies\": {\r\n \"locationPlacementId\": \"Internal_2014-09-01\",\r\n \"quotaId\": \"Internal_2014-09-01\"\r\n }\r\n },\r\n {\r\n \"id\": \"/subscriptions/2c224e7e-3ef5-431d-a57b-e71f4662e3a6\",\r\n \"subscriptionId\": \"2c224e7e-3ef5-431d-a57b-e71f4662e3a6\",\r\n \"displayName\": \"Node CLI Test\",\r\n \"state\": \"Enabled\",\r\n \"subscriptionPolicies\": {\r\n \"locationPlacementId\": \"Internal_2014-09-01\",\r\n \"quotaId\": \"Internal_2014-09-01\"\r\n }\r\n },\r\n {\r\n \"id\": \"/subscriptions/6b085460-5f21-477e-ba44-1035046e9101\",\r\n \"subscriptionId\": \"6b085460-5f21-477e-ba44-1035046e9101\",\r\n \"displayName\": \"Azure SDK Infrastructure\",\r\n \"state\": \"Enabled\",\r\n \"subscriptionPolicies\": {\r\n \"locationPlacementId\": \"Internal_2014-09-01\",\r\n \"quotaId\": \"Internal_2014-09-01\"\r\n }\r\n },\r\n {\r\n \"id\": \"/subscriptions/db1ab6f0-4769-4b27-930e-01e2ef9c123c\",\r\n \"subscriptionId\": \"db1ab6f0-4769-4b27-930e-01e2ef9c123c\",\r\n \"displayName\": \"Azure SDK sandbox\",\r\n \"state\": \"Enabled\",\r\n \"subscriptionPolicies\": {\r\n \"locationPlacementId\": \"Internal_2014-09-01\",\r\n \"quotaId\": \"Internal_2014-09-01\"\r\n }\r\n }\r\n ]\r\n}",
62+
"ResponseHeaders": {
63+
"Content-Length": [
64+
"1081"
65+
],
66+
"Content-Type": [
67+
"application/json; charset=utf-8"
68+
],
69+
"Expires": [
70+
"-1"
71+
],
72+
"Pragma": [
73+
"no-cache"
74+
],
75+
"x-ms-ratelimit-remaining-tenant-reads": [
76+
"14998"
77+
],
78+
"x-ms-request-id": [
79+
"26b98034-05ee-4844-ac72-a8c02a305858"
80+
],
81+
"x-ms-correlation-request-id": [
82+
"26b98034-05ee-4844-ac72-a8c02a305858"
83+
],
84+
"x-ms-routing-request-id": [
85+
"WESTUS:20151022T180627Z:26b98034-05ee-4844-ac72-a8c02a305858"
86+
],
87+
"Strict-Transport-Security": [
88+
"max-age=31536000; includeSubDomains"
89+
],
90+
"Cache-Control": [
91+
"no-cache"
92+
],
93+
"Date": [
94+
"Thu, 22 Oct 2015 18:06:26 GMT"
95+
]
96+
},
97+
"StatusCode": 200
98+
},
399
{
4100
"RequestUri": "/subscriptions?api-version=2014-04-01-preview",
5101
"EncodedRequestUri": "L3N1YnNjcmlwdGlvbnM/YXBpLXZlcnNpb249MjAxNC0wNC0wMS1wcmV2aWV3",
@@ -28,13 +124,13 @@
28124
"14997"
29125
],
30126
"x-ms-request-id": [
31-
"284d131d-ec1d-473e-82b2-022824dbd382"
127+
"af0e42bf-875b-4457-963e-24fa3470061e"
32128
],
33129
"x-ms-correlation-request-id": [
34-
"284d131d-ec1d-473e-82b2-022824dbd382"
130+
"af0e42bf-875b-4457-963e-24fa3470061e"
35131
],
36132
"x-ms-routing-request-id": [
37-
"WESTUS:20151022T003227Z:284d131d-ec1d-473e-82b2-022824dbd382"
133+
"WESTUS:20151022T180627Z:af0e42bf-875b-4457-963e-24fa3470061e"
38134
],
39135
"Strict-Transport-Security": [
40136
"max-age=31536000; includeSubDomains"
@@ -43,7 +139,7 @@
43139
"no-cache"
44140
],
45141
"Date": [
46-
"Thu, 22 Oct 2015 00:32:27 GMT"
142+
"Thu, 22 Oct 2015 18:06:27 GMT"
47143
]
48144
},
49145
"StatusCode": 200
@@ -76,13 +172,13 @@
76172
"14996"
77173
],
78174
"x-ms-request-id": [
79-
"55b62765-1a90-4adf-86a8-68ad7640328a"
175+
"4bc6ff63-684d-423f-87c4-ede93d0b098a"
80176
],
81177
"x-ms-correlation-request-id": [
82-
"55b62765-1a90-4adf-86a8-68ad7640328a"
178+
"4bc6ff63-684d-423f-87c4-ede93d0b098a"
83179
],
84180
"x-ms-routing-request-id": [
85-
"WESTUS:20151022T003228Z:55b62765-1a90-4adf-86a8-68ad7640328a"
181+
"WESTUS:20151022T180627Z:4bc6ff63-684d-423f-87c4-ede93d0b098a"
86182
],
87183
"Strict-Transport-Security": [
88184
"max-age=31536000; includeSubDomains"
@@ -91,7 +187,7 @@
91187
"no-cache"
92188
],
93189
"Date": [
94-
"Thu, 22 Oct 2015 00:32:28 GMT"
190+
"Thu, 22 Oct 2015 18:06:27 GMT"
95191
]
96192
},
97193
"StatusCode": 200
@@ -124,13 +220,13 @@
124220
"14995"
125221
],
126222
"x-ms-request-id": [
127-
"e56eae11-deb0-40ff-8247-33e26f6584d4"
223+
"20764464-9863-4fc0-9228-3bacb5690b52"
128224
],
129225
"x-ms-correlation-request-id": [
130-
"e56eae11-deb0-40ff-8247-33e26f6584d4"
226+
"20764464-9863-4fc0-9228-3bacb5690b52"
131227
],
132228
"x-ms-routing-request-id": [
133-
"WESTUS:20151022T003236Z:e56eae11-deb0-40ff-8247-33e26f6584d4"
229+
"WESTUS:20151022T180628Z:20764464-9863-4fc0-9228-3bacb5690b52"
134230
],
135231
"Strict-Transport-Security": [
136232
"max-age=31536000; includeSubDomains"
@@ -139,7 +235,7 @@
139235
"no-cache"
140236
],
141237
"Date": [
142-
"Thu, 22 Oct 2015 00:32:36 GMT"
238+
"Thu, 22 Oct 2015 18:06:27 GMT"
143239
]
144240
},
145241
"StatusCode": 200
@@ -172,13 +268,13 @@
172268
"14994"
173269
],
174270
"x-ms-request-id": [
175-
"dc675c1b-2b93-46f0-8398-71b55a651c1c"
271+
"dc63ecd4-c5ee-46a4-876e-fb6ffc3ac8fe"
176272
],
177273
"x-ms-correlation-request-id": [
178-
"dc675c1b-2b93-46f0-8398-71b55a651c1c"
274+
"dc63ecd4-c5ee-46a4-876e-fb6ffc3ac8fe"
179275
],
180276
"x-ms-routing-request-id": [
181-
"WESTUS:20151022T003237Z:dc675c1b-2b93-46f0-8398-71b55a651c1c"
277+
"WESTUS:20151022T180628Z:dc63ecd4-c5ee-46a4-876e-fb6ffc3ac8fe"
182278
],
183279
"Strict-Transport-Security": [
184280
"max-age=31536000; includeSubDomains"
@@ -187,7 +283,7 @@
187283
"no-cache"
188284
],
189285
"Date": [
190-
"Thu, 22 Oct 2015 00:32:37 GMT"
286+
"Thu, 22 Oct 2015 18:06:28 GMT"
191287
]
192288
},
193289
"StatusCode": 200
@@ -220,13 +316,13 @@
220316
"14993"
221317
],
222318
"x-ms-request-id": [
223-
"c2c75a0f-db5e-4899-8957-699be8cab5d6"
319+
"2ee70574-ce24-40e7-81a2-d94a9f7bd48b"
224320
],
225321
"x-ms-correlation-request-id": [
226-
"c2c75a0f-db5e-4899-8957-699be8cab5d6"
322+
"2ee70574-ce24-40e7-81a2-d94a9f7bd48b"
227323
],
228324
"x-ms-routing-request-id": [
229-
"WESTUS:20151022T003238Z:c2c75a0f-db5e-4899-8957-699be8cab5d6"
325+
"WESTUS:20151022T180629Z:2ee70574-ce24-40e7-81a2-d94a9f7bd48b"
230326
],
231327
"Strict-Transport-Security": [
232328
"max-age=31536000; includeSubDomains"
@@ -235,7 +331,7 @@
235331
"no-cache"
236332
],
237333
"Date": [
238-
"Thu, 22 Oct 2015 00:32:38 GMT"
334+
"Thu, 22 Oct 2015 18:06:28 GMT"
239335
]
240336
},
241337
"StatusCode": 200
@@ -268,13 +364,13 @@
268364
"14992"
269365
],
270366
"x-ms-request-id": [
271-
"5ad9419b-700e-4541-9599-356c1a8fd765"
367+
"fc489996-6e3a-42c3-9a2f-8c4d13daf330"
272368
],
273369
"x-ms-correlation-request-id": [
274-
"5ad9419b-700e-4541-9599-356c1a8fd765"
370+
"fc489996-6e3a-42c3-9a2f-8c4d13daf330"
275371
],
276372
"x-ms-routing-request-id": [
277-
"WESTUS:20151022T003239Z:5ad9419b-700e-4541-9599-356c1a8fd765"
373+
"WESTUS:20151022T180629Z:fc489996-6e3a-42c3-9a2f-8c4d13daf330"
278374
],
279375
"Strict-Transport-Security": [
280376
"max-age=31536000; includeSubDomains"
@@ -283,7 +379,7 @@
283379
"no-cache"
284380
],
285381
"Date": [
286-
"Thu, 22 Oct 2015 00:32:39 GMT"
382+
"Thu, 22 Oct 2015 18:06:28 GMT"
287383
]
288384
},
289385
"StatusCode": 200
@@ -316,13 +412,13 @@
316412
"14999"
317413
],
318414
"x-ms-request-id": [
319-
"6c65c5d8-7009-4a55-8eae-7433886b8425"
415+
"6830d8eb-637a-4150-b016-7aa4f69013de"
320416
],
321417
"x-ms-correlation-request-id": [
322-
"6c65c5d8-7009-4a55-8eae-7433886b8425"
418+
"6830d8eb-637a-4150-b016-7aa4f69013de"
323419
],
324420
"x-ms-routing-request-id": [
325-
"WESTUS:20151022T003238Z:6c65c5d8-7009-4a55-8eae-7433886b8425"
421+
"WESTUS:20151022T180627Z:6830d8eb-637a-4150-b016-7aa4f69013de"
326422
],
327423
"Strict-Transport-Security": [
328424
"max-age=31536000; includeSubDomains"
@@ -331,7 +427,7 @@
331427
"no-cache"
332428
],
333429
"Date": [
334-
"Thu, 22 Oct 2015 00:32:37 GMT"
430+
"Thu, 22 Oct 2015 18:06:27 GMT"
335431
]
336432
},
337433
"StatusCode": 200

src/ResourceManager/Profile/Commands.Profile.Test/SubscriptionCmdletTests.ps1

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ function Test-PipingWithContext
5252
$name = $firstSubscription.SubscriptionName
5353
$nameContext = Get-AzureRmSubscription -SubscriptionName $name | Set-AzureRmContext
5454
$idContext = Get-AzureRmSubscription -SubscriptionId $id | Set-AzureRmContext
55+
$contextByName = Set-AzureRmContext -SubscriptionName $name
5556
Assert-True { $nameContext -ne $null }
5657
Assert-True { $nameContext.Subscription -ne $null }
5758
Assert-True { $nameContext.Subscription.SubscriptionId -ne $null }
@@ -62,6 +63,11 @@ function Test-PipingWithContext
6263
Assert-True { $idContext.Subscription.SubscriptionName -ne $null }
6364
Assert-AreEqual $idContext.Subscription.SubscriptionId $nameContext.Subscription.SubscriptionId
6465
Assert-AreEqual $idContext.Subscription.SubscriptionName $nameContext.Subscription.SubscriptionName
66+
Assert-True { $contextByName -ne $null }
67+
Assert-True { $contextByName.Subscription -ne $null }
68+
Assert-True { $contextByName.Subscription.SubscriptionId -ne $null }
69+
Assert-True { $contextByName.Subscription.SubscriptionName -ne $null }
70+
Assert-AreEqual $contextByName.Subscription.SubscriptionName $nameContext.Subscription.SubscriptionName
6571
}
6672

6773
function Test-SetAzureRmContextEndToEnd

src/ResourceManager/Profile/Commands.Profile/Context/SetAzureRMContext.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ protected override void ProcessRecord()
6464

6565
if (string.IsNullOrWhiteSpace(TenantId))
6666
{
67-
WriteWarning(
67+
WriteVerbose(
6868
string.Format(
6969
Resources.CurrentTenantInUse,
7070
tenantId));

0 commit comments

Comments
 (0)