@@ -290,6 +290,10 @@ public void AddAzureAccountReturnsAccountWithAllSubscriptionsInCsmMode()
290290 Assert . True ( account . GetSubscriptions ( client . Profile ) . Any ( s => s . Id == new Guid ( csmSubscription1 . SubscriptionId ) ) ) ;
291291 }
292292
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>
293297 [ Fact ]
294298 public void AddAzureAccountWithImpersonatedGuestWithNoSubscriptions ( )
295299 {
@@ -326,6 +330,10 @@ public void AddAzureAccountWithImpersonatedGuestWithNoSubscriptions()
326330 Assert . Equal ( "UserA" , subrdfe1 . Account ) ;
327331 }
328332
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>
329337 [ Fact ]
330338 public void AddAzureAccountWithImpersonatedGuestWithSubscriptions ( )
331339 {
@@ -346,7 +354,8 @@ public void AddAzureAccountWithImpersonatedGuestWithSubscriptions()
346354 ProfileClient . DataStore = dataStore ;
347355 ProfileClient client = new ProfileClient ( ) ;
348356
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 ) ;
350359
351360 Assert . Equal ( "UserA" , account . Id ) ;
352361 Assert . Equal ( 1 , account . GetSubscriptions ( client . Profile ) . Count ) ;
@@ -363,6 +372,39 @@ public void AddAzureAccountWithImpersonatedGuestWithSubscriptions()
363372 Assert . Equal ( "UserA" , subrdfe1 . Account ) ;
364373 Assert . Equal ( "UserB" , subGuest . Account ) ;
365374 }
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+ }
366408
367409 [ Fact ]
368410 public void GetAzureAccountReturnsAccountWithSubscriptions ( )
0 commit comments