@@ -365,11 +365,9 @@ public void AppServiceManagedIdentity()
365
365
{
366
366
AzureSessionInitializer . InitializeAzureSession ( ) ;
367
367
var tenant = Guid . NewGuid ( ) . ToString ( ) ;
368
- var userId = Guid . NewGuid ( ) . ToString ( ) ;
369
368
var environment = AzureEnvironment . PublicEnvironments [ "AzureCloud" ] ;
370
369
var account = new AzureAccount
371
370
{
372
- Id = userId ,
373
371
Type = AzureAccount . AccountType . ManagedService
374
372
} ;
375
373
const string resource = @"https://management.azure.com/" ;
@@ -402,7 +400,7 @@ public void AppServiceManagedIdentity()
402
400
403
401
[ Fact ]
404
402
[ Trait ( Category . AcceptanceType , Category . CheckIn ) ]
405
- public void AppServiceManagedIdentityWithDataPlane ( )
403
+ public void AppServiceUserManagedIdentityWithDataPlane ( )
406
404
{
407
405
AzureSessionInitializer . InitializeAzureSession ( ) ;
408
406
var tenant = Guid . NewGuid ( ) . ToString ( ) ;
@@ -415,6 +413,45 @@ public void AppServiceManagedIdentityWithDataPlane()
415
413
} ;
416
414
const string resource = @"https://vault.azure.com/" ;
417
415
const string endpoint = @"http://127.0.0.1:41217/MSI/token/" ;
416
+ var expectedUri = $ "{ endpoint } ?resource={ resource } &api-version=2017-09-01&clientid={ userId } ";
417
+ account . SetProperty ( AzureAccount . Property . MSILoginUri , endpoint ) ;
418
+ account . SetProperty ( AzureAccount . Property . MSILoginSecret , @"bar" ) ;
419
+ const string expectedAccessToken = "foo" ;
420
+ var expectedExpiresOn = DateTimeOffset . Parse ( "1/23/2019 7:15:42 AM +00:00" ) ;
421
+ var responses = new Dictionary < string , ManagedServiceAppServiceTokenInfo > ( StringComparer . OrdinalIgnoreCase )
422
+ {
423
+ {
424
+ expectedUri ,
425
+ new ManagedServiceAppServiceTokenInfo ( )
426
+ {
427
+ AccessToken = expectedAccessToken ,
428
+ ExpiresOn = expectedExpiresOn ,
429
+ Resource = resource ,
430
+ TokenType = "Bearer" ,
431
+ }
432
+ }
433
+ } ;
434
+ AzureSession . Instance . RegisterComponent ( HttpClientOperationsFactory . Name , ( ) => TestHttpOperationsFactory . Create ( responses , _output ) , true ) ;
435
+ var msat = new ManagedServiceAppServiceAccessToken ( account , environment , environment . GetEndpoint ( resource ) ?? resource , tenant ) ;
436
+ Assert . Equal ( expectedUri , msat . RequestUris . Peek ( ) ) ;
437
+ var accessToken = msat . AccessToken ;
438
+ Assert . Equal ( expectedAccessToken , accessToken ) ;
439
+ Assert . Equal ( expectedExpiresOn , msat . ExpiresOn ) ;
440
+ }
441
+
442
+ [ Fact ]
443
+ [ Trait ( Category . AcceptanceType , Category . CheckIn ) ]
444
+ public void AppServiceManagedIdentityWithDataPlane ( )
445
+ {
446
+ AzureSessionInitializer . InitializeAzureSession ( ) ;
447
+ var tenant = Guid . NewGuid ( ) . ToString ( ) ;
448
+ var environment = AzureEnvironment . PublicEnvironments [ "AzureCloud" ] ;
449
+ var account = new AzureAccount
450
+ {
451
+ Type = AzureAccount . AccountType . ManagedService
452
+ } ;
453
+ const string resource = @"https://vault.azure.com/" ;
454
+ const string endpoint = @"http://127.0.0.1:41217/MSI/token/" ;
418
455
var expectedUri = $ "{ endpoint } ?resource={ resource } &api-version=2017-09-01";
419
456
account . SetProperty ( AzureAccount . Property . MSILoginUri , endpoint ) ;
420
457
account . SetProperty ( AzureAccount . Property . MSILoginSecret , @"bar" ) ;
@@ -447,11 +484,9 @@ public void AppServiceManagedIdentityWithServiceManagement()
447
484
{
448
485
AzureSessionInitializer . InitializeAzureSession ( ) ;
449
486
var tenant = Guid . NewGuid ( ) . ToString ( ) ;
450
- var userId = Guid . NewGuid ( ) . ToString ( ) ;
451
487
var environment = AzureEnvironment . PublicEnvironments [ "AzureCloud" ] ;
452
488
var account = new AzureAccount
453
489
{
454
- Id = userId ,
455
490
Type = AzureAccount . AccountType . ManagedService
456
491
} ;
457
492
const string resource = @"https://management.azure.com/" ;
0 commit comments