Skip to content

Commit 25f5fe3

Browse files
committed
Merge pull request Azure#1171 from hovsepm/dev
[#105517610] Enable login and creating context with no subscriptions
2 parents 842678b + 98534cd commit 25f5fe3

17 files changed

+388
-121
lines changed

src/ResourceManager/Profile/Commands.Profile.Test/AzureRMProfileTests.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ public void SubscriptionNotFoundDoesNotThrow()
107107
var subResults = new List<AzureSubscription>(client.ListSubscriptions());
108108
Assert.Equal(1, subResults.Count);
109109
AzureSubscription subValue;
110-
Assert.False(client.TryGetSubscription(DefaultTenant.ToString(), DefaultSubscription.ToString(), out subValue));
110+
Assert.True(client.TryGetSubscription(DefaultTenant.ToString(), DefaultSubscription.ToString(), out subValue));
111111
}
112112

113113
[Fact]
@@ -123,14 +123,14 @@ public void NoTenantsDoesNotThrow()
123123

124124
[Fact]
125125
[Trait(Category.AcceptanceType, Category.CheckIn)]
126-
public void NoSubscriptionsInListThrows()
126+
public void NoSubscriptionsInListDoesNotThrow()
127127
{
128128
var tenants = new List<string> { DefaultTenant.ToString() };
129129
var subscriptions = new List<string> () ;
130130
var client = SetupTestEnvironment(tenants, subscriptions);
131131
Assert.Equal(0, client.ListSubscriptions().Count());
132132
AzureSubscription subValue;
133-
Assert.False(client.TryGetSubscription(DefaultTenant.ToString(), DefaultSubscription.ToString(), out subValue));
133+
Assert.True(client.TryGetSubscription(DefaultTenant.ToString(), DefaultSubscription.ToString(), out subValue));
134134
}
135135

136136
[Fact]

src/ResourceManager/Profile/Commands.Profile.Test/Commands.Profile.Test.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,9 @@
214214
<None Include="SessionRecords\Microsoft.Azure.Commands.Profile.Test.SubscriptionCmdletTests\PipingWithRmContextWorks.json">
215215
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
216216
</None>
217+
<None Include="SessionRecords\Microsoft.Azure.Commands.Profile.Test.SubscriptionCmdletTests\SetAzureRmContextWithoutSubscription.json">
218+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
219+
</None>
217220
<None Include="SessionRecords\Microsoft.Azure.Commands.Profile.Test.SubscriptionCmdletTests\SetAzureRmContextWorks.json">
218221
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
219222
</None>

src/ResourceManager/Profile/Commands.Profile.Test/LoginCmdletTests.cs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,5 +165,26 @@ public void LoginWithBothSubscriptionIdAndNameThrowsCloudException()
165165
Assert.Throws<PSInvalidOperationException>(() => cmdlt.ExecuteCmdlet());
166166
cmdlt.InvokeEndProcessing();
167167
}
168+
169+
[Fact]
170+
[Trait(Category.RunType, Category.LiveOnly)]
171+
public void LoginWithRbacTenantOnly()
172+
{
173+
var cmdlt = new AddAzureRMAccountCommand();
174+
// Setup
175+
// NOTE: Use [email protected] credentials for this test case
176+
cmdlt.CommandRuntime = commandRuntimeMock;
177+
cmdlt.TenantId = "1449d5b7-8a83-47db-ae4c-9b03e888bad0";
178+
179+
// Act
180+
cmdlt.InvokeBeginProcessing();
181+
cmdlt.ExecuteCmdlet();
182+
cmdlt.InvokeEndProcessing();
183+
184+
Assert.NotNull(AzureRmProfileProvider.Instance.Profile.Context);
185+
Assert.Equal("rbactest.onmicrosoft.com", AzureRmProfileProvider.Instance.Profile.Context.Tenant.Domain);
186+
Assert.Equal(cmdlt.TenantId, AzureRmProfileProvider.Instance.Profile.Context.Tenant.Id.ToString());
187+
Assert.Null(AzureRmProfileProvider.Instance.Profile.Context.Subscription);
188+
}
168189
}
169190
}

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

Lines changed: 44 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,16 @@
2525
"no-cache"
2626
],
2727
"x-ms-ratelimit-remaining-tenant-reads": [
28-
"14999"
28+
"14998"
2929
],
3030
"x-ms-request-id": [
31-
"ab8756d0-4404-4a60-ae6e-2653656c0b23"
31+
"f43c6b67-d3cd-4cfb-a6e5-818f59e4cb1d"
3232
],
3333
"x-ms-correlation-request-id": [
34-
"ab8756d0-4404-4a60-ae6e-2653656c0b23"
34+
"f43c6b67-d3cd-4cfb-a6e5-818f59e4cb1d"
3535
],
3636
"x-ms-routing-request-id": [
37-
"WESTUS:20151022T180626Z:ab8756d0-4404-4a60-ae6e-2653656c0b23"
37+
"WESTUS:20151026T233322Z:f43c6b67-d3cd-4cfb-a6e5-818f59e4cb1d"
3838
],
3939
"Strict-Transport-Security": [
4040
"max-age=31536000; includeSubDomains"
@@ -43,7 +43,7 @@
4343
"no-cache"
4444
],
4545
"Date": [
46-
"Thu, 22 Oct 2015 18:06:26 GMT"
46+
"Mon, 26 Oct 2015 23:33:21 GMT"
4747
]
4848
},
4949
"StatusCode": 200
@@ -73,16 +73,16 @@
7373
"no-cache"
7474
],
7575
"x-ms-ratelimit-remaining-tenant-reads": [
76-
"14998"
76+
"14997"
7777
],
7878
"x-ms-request-id": [
79-
"26b98034-05ee-4844-ac72-a8c02a305858"
79+
"83c4e352-6d75-4bcb-8c20-0f10ca413f38"
8080
],
8181
"x-ms-correlation-request-id": [
82-
"26b98034-05ee-4844-ac72-a8c02a305858"
82+
"83c4e352-6d75-4bcb-8c20-0f10ca413f38"
8383
],
8484
"x-ms-routing-request-id": [
85-
"WESTUS:20151022T180627Z:26b98034-05ee-4844-ac72-a8c02a305858"
85+
"WESTUS:20151026T233322Z:83c4e352-6d75-4bcb-8c20-0f10ca413f38"
8686
],
8787
"Strict-Transport-Security": [
8888
"max-age=31536000; includeSubDomains"
@@ -91,7 +91,7 @@
9191
"no-cache"
9292
],
9393
"Date": [
94-
"Thu, 22 Oct 2015 18:06:26 GMT"
94+
"Mon, 26 Oct 2015 23:33:22 GMT"
9595
]
9696
},
9797
"StatusCode": 200
@@ -121,16 +121,16 @@
121121
"no-cache"
122122
],
123123
"x-ms-ratelimit-remaining-tenant-reads": [
124-
"14997"
124+
"14996"
125125
],
126126
"x-ms-request-id": [
127-
"af0e42bf-875b-4457-963e-24fa3470061e"
127+
"7f523dc6-e56c-4535-822e-0e155151cc6c"
128128
],
129129
"x-ms-correlation-request-id": [
130-
"af0e42bf-875b-4457-963e-24fa3470061e"
130+
"7f523dc6-e56c-4535-822e-0e155151cc6c"
131131
],
132132
"x-ms-routing-request-id": [
133-
"WESTUS:20151022T180627Z:af0e42bf-875b-4457-963e-24fa3470061e"
133+
"WESTUS:20151026T233323Z:7f523dc6-e56c-4535-822e-0e155151cc6c"
134134
],
135135
"Strict-Transport-Security": [
136136
"max-age=31536000; includeSubDomains"
@@ -139,7 +139,7 @@
139139
"no-cache"
140140
],
141141
"Date": [
142-
"Thu, 22 Oct 2015 18:06:27 GMT"
142+
"Mon, 26 Oct 2015 23:33:23 GMT"
143143
]
144144
},
145145
"StatusCode": 200
@@ -169,16 +169,16 @@
169169
"no-cache"
170170
],
171171
"x-ms-ratelimit-remaining-tenant-reads": [
172-
"14996"
172+
"14995"
173173
],
174174
"x-ms-request-id": [
175-
"4bc6ff63-684d-423f-87c4-ede93d0b098a"
175+
"5b721cba-1691-4a90-a6df-40fbf2c99635"
176176
],
177177
"x-ms-correlation-request-id": [
178-
"4bc6ff63-684d-423f-87c4-ede93d0b098a"
178+
"5b721cba-1691-4a90-a6df-40fbf2c99635"
179179
],
180180
"x-ms-routing-request-id": [
181-
"WESTUS:20151022T180627Z:4bc6ff63-684d-423f-87c4-ede93d0b098a"
181+
"WESTUS:20151026T233324Z:5b721cba-1691-4a90-a6df-40fbf2c99635"
182182
],
183183
"Strict-Transport-Security": [
184184
"max-age=31536000; includeSubDomains"
@@ -187,7 +187,7 @@
187187
"no-cache"
188188
],
189189
"Date": [
190-
"Thu, 22 Oct 2015 18:06:27 GMT"
190+
"Mon, 26 Oct 2015 23:33:23 GMT"
191191
]
192192
},
193193
"StatusCode": 200
@@ -217,16 +217,16 @@
217217
"no-cache"
218218
],
219219
"x-ms-ratelimit-remaining-tenant-reads": [
220-
"14995"
220+
"14994"
221221
],
222222
"x-ms-request-id": [
223-
"20764464-9863-4fc0-9228-3bacb5690b52"
223+
"5538ca2e-3923-4c65-b042-67c3529f6c67"
224224
],
225225
"x-ms-correlation-request-id": [
226-
"20764464-9863-4fc0-9228-3bacb5690b52"
226+
"5538ca2e-3923-4c65-b042-67c3529f6c67"
227227
],
228228
"x-ms-routing-request-id": [
229-
"WESTUS:20151022T180628Z:20764464-9863-4fc0-9228-3bacb5690b52"
229+
"WESTUS:20151026T233325Z:5538ca2e-3923-4c65-b042-67c3529f6c67"
230230
],
231231
"Strict-Transport-Security": [
232232
"max-age=31536000; includeSubDomains"
@@ -235,7 +235,7 @@
235235
"no-cache"
236236
],
237237
"Date": [
238-
"Thu, 22 Oct 2015 18:06:27 GMT"
238+
"Mon, 26 Oct 2015 23:33:24 GMT"
239239
]
240240
},
241241
"StatusCode": 200
@@ -265,16 +265,16 @@
265265
"no-cache"
266266
],
267267
"x-ms-ratelimit-remaining-tenant-reads": [
268-
"14994"
268+
"14993"
269269
],
270270
"x-ms-request-id": [
271-
"dc63ecd4-c5ee-46a4-876e-fb6ffc3ac8fe"
271+
"decc0586-de39-4dc4-95d5-d87dc1919af3"
272272
],
273273
"x-ms-correlation-request-id": [
274-
"dc63ecd4-c5ee-46a4-876e-fb6ffc3ac8fe"
274+
"decc0586-de39-4dc4-95d5-d87dc1919af3"
275275
],
276276
"x-ms-routing-request-id": [
277-
"WESTUS:20151022T180628Z:dc63ecd4-c5ee-46a4-876e-fb6ffc3ac8fe"
277+
"WESTUS:20151026T233325Z:decc0586-de39-4dc4-95d5-d87dc1919af3"
278278
],
279279
"Strict-Transport-Security": [
280280
"max-age=31536000; includeSubDomains"
@@ -283,7 +283,7 @@
283283
"no-cache"
284284
],
285285
"Date": [
286-
"Thu, 22 Oct 2015 18:06:28 GMT"
286+
"Mon, 26 Oct 2015 23:33:25 GMT"
287287
]
288288
},
289289
"StatusCode": 200
@@ -313,16 +313,16 @@
313313
"no-cache"
314314
],
315315
"x-ms-ratelimit-remaining-tenant-reads": [
316-
"14993"
316+
"14992"
317317
],
318318
"x-ms-request-id": [
319-
"2ee70574-ce24-40e7-81a2-d94a9f7bd48b"
319+
"7774a024-8a75-4124-8aa0-f35b5a6001fb"
320320
],
321321
"x-ms-correlation-request-id": [
322-
"2ee70574-ce24-40e7-81a2-d94a9f7bd48b"
322+
"7774a024-8a75-4124-8aa0-f35b5a6001fb"
323323
],
324324
"x-ms-routing-request-id": [
325-
"WESTUS:20151022T180629Z:2ee70574-ce24-40e7-81a2-d94a9f7bd48b"
325+
"WESTUS:20151026T233326Z:7774a024-8a75-4124-8aa0-f35b5a6001fb"
326326
],
327327
"Strict-Transport-Security": [
328328
"max-age=31536000; includeSubDomains"
@@ -331,7 +331,7 @@
331331
"no-cache"
332332
],
333333
"Date": [
334-
"Thu, 22 Oct 2015 18:06:28 GMT"
334+
"Mon, 26 Oct 2015 23:33:25 GMT"
335335
]
336336
},
337337
"StatusCode": 200
@@ -361,16 +361,16 @@
361361
"no-cache"
362362
],
363363
"x-ms-ratelimit-remaining-tenant-reads": [
364-
"14992"
364+
"14991"
365365
],
366366
"x-ms-request-id": [
367-
"fc489996-6e3a-42c3-9a2f-8c4d13daf330"
367+
"3041f6a7-40fa-48d8-b36c-7640f5e82559"
368368
],
369369
"x-ms-correlation-request-id": [
370-
"fc489996-6e3a-42c3-9a2f-8c4d13daf330"
370+
"3041f6a7-40fa-48d8-b36c-7640f5e82559"
371371
],
372372
"x-ms-routing-request-id": [
373-
"WESTUS:20151022T180629Z:fc489996-6e3a-42c3-9a2f-8c4d13daf330"
373+
"WESTUS:20151026T233326Z:3041f6a7-40fa-48d8-b36c-7640f5e82559"
374374
],
375375
"Strict-Transport-Security": [
376376
"max-age=31536000; includeSubDomains"
@@ -379,7 +379,7 @@
379379
"no-cache"
380380
],
381381
"Date": [
382-
"Thu, 22 Oct 2015 18:06:28 GMT"
382+
"Mon, 26 Oct 2015 23:33:26 GMT"
383383
]
384384
},
385385
"StatusCode": 200
@@ -412,13 +412,13 @@
412412
"14999"
413413
],
414414
"x-ms-request-id": [
415-
"6830d8eb-637a-4150-b016-7aa4f69013de"
415+
"8ef812b2-9da5-4d2b-a000-cb830efad4e3"
416416
],
417417
"x-ms-correlation-request-id": [
418-
"6830d8eb-637a-4150-b016-7aa4f69013de"
418+
"8ef812b2-9da5-4d2b-a000-cb830efad4e3"
419419
],
420420
"x-ms-routing-request-id": [
421-
"WESTUS:20151022T180627Z:6830d8eb-637a-4150-b016-7aa4f69013de"
421+
"WESTUS:20151026T233324Z:8ef812b2-9da5-4d2b-a000-cb830efad4e3"
422422
],
423423
"Strict-Transport-Security": [
424424
"max-age=31536000; includeSubDomains"
@@ -427,7 +427,7 @@
427427
"no-cache"
428428
],
429429
"Date": [
430-
"Thu, 22 Oct 2015 18:06:27 GMT"
430+
"Mon, 26 Oct 2015 23:33:23 GMT"
431431
]
432432
},
433433
"StatusCode": 200

0 commit comments

Comments
 (0)