@@ -290,6 +290,10 @@ public void AddAzureAccountReturnsAccountWithAllSubscriptionsInCsmMode()
290
290
Assert . True ( account . GetSubscriptions ( client . Profile ) . Any ( s => s . Id == new Guid ( csmSubscription1 . SubscriptionId ) ) ) ;
291
291
}
292
292
293
+ /// <summary>
294
+ /// Verify that if a user has a different identity in one tenant, the identity is not added if it has no
295
+ /// access to subscriptions
296
+ /// </summary>
293
297
[ Fact ]
294
298
public void AddAzureAccountWithImpersonatedGuestWithNoSubscriptions ( )
295
299
{
@@ -326,6 +330,10 @@ public void AddAzureAccountWithImpersonatedGuestWithNoSubscriptions()
326
330
Assert . Equal ( "UserA" , subrdfe1 . Account ) ;
327
331
}
328
332
333
+ /// <summary>
334
+ /// Verify that multiple accounts can be added if a user has different identitities in different domains, linked to the same login
335
+ /// Verify that subscriptions with admin access forall accounts are added
336
+ /// </summary>
329
337
[ Fact ]
330
338
public void AddAzureAccountWithImpersonatedGuestWithSubscriptions ( )
331
339
{
@@ -346,7 +354,8 @@ public void AddAzureAccountWithImpersonatedGuestWithSubscriptions()
346
354
ProfileClient . DataStore = dataStore ;
347
355
ProfileClient client = new ProfileClient ( ) ;
348
356
349
- var account = client . AddAccountAndLoadSubscriptions ( new AzureAccount { Id = "UserA" , Type = AzureAccount . AccountType . User } , AzureEnvironment . PublicEnvironments [ EnvironmentName . AzureCloud ] , null ) ;
357
+ var account = client . AddAccountAndLoadSubscriptions ( new AzureAccount { Id = "UserA" , Type = AzureAccount . AccountType . User } ,
358
+ AzureEnvironment . PublicEnvironments [ EnvironmentName . AzureCloud ] , null ) ;
350
359
351
360
Assert . Equal ( "UserA" , account . Id ) ;
352
361
Assert . Equal ( 1 , account . GetSubscriptions ( client . Profile ) . Count ) ;
@@ -363,6 +372,39 @@ public void AddAzureAccountWithImpersonatedGuestWithSubscriptions()
363
372
Assert . Equal ( "UserA" , subrdfe1 . Account ) ;
364
373
Assert . Equal ( "UserB" , subGuest . Account ) ;
365
374
}
375
+ /// <summary>
376
+ /// Test that when account is added more than once with different capitalization, only a single account is added
377
+ /// and that accounts can be retrieved case-insensitively
378
+ /// </summary>
379
+ [ Fact ]
380
+ public void AddAzureAccountIsCaseInsensitive ( )
381
+ {
382
+ SetMocks ( new [ ] { rdfeSubscription1 , guestRdfeSubscription } . ToList ( ) , new List < Azure . Subscriptions . Models . Subscription > ( ) , new [ ] { commonTenant , guestTenant } . ToList ( ) ,
383
+ ( userAccount , environment , tenant ) =>
384
+ {
385
+ var token = new MockAccessToken
386
+ {
387
+ UserId = tenant == commonTenant . TenantId ? userAccount . Id : "USERA" ,
388
+ AccessToken = "def" ,
389
+ LoginType = LoginType . OrgId
390
+ } ;
391
+ userAccount . Id = token . UserId ;
392
+ return token ;
393
+ } ) ;
394
+ MockDataStore dataStore = new MockDataStore ( ) ;
395
+ dataStore . VirtualStore [ oldProfileDataPath ] = oldProfileData ;
396
+ ProfileClient . DataStore = dataStore ;
397
+ ProfileClient client = new ProfileClient ( ) ;
398
+
399
+ var account = client . AddAccountAndLoadSubscriptions ( new AzureAccount { Id = "UserA" , Type = AzureAccount . AccountType . User } ,
400
+ AzureEnvironment . PublicEnvironments [ EnvironmentName . AzureCloud ] , null ) ;
401
+
402
+ var userA = client . GetAccount ( "UserA" ) ;
403
+ var secondUserA = client . GetAccount ( "USERA" ) ;
404
+ Assert . NotNull ( userA ) ;
405
+ Assert . NotNull ( secondUserA ) ;
406
+ Assert . Equal ( userA . Id , secondUserA . Id ) ;
407
+ }
366
408
367
409
[ Fact ]
368
410
public void GetAzureAccountReturnsAccountWithSubscriptions ( )
0 commit comments