Skip to content

Commit c9f6eb0

Browse files
authored
Merge pull request Azure#9892 from erich-wang/fix-user-msi2
fix userId in system managed identity test cases
2 parents 7142936 + 7e893ad commit c9f6eb0

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/Accounts/Authentication.Test/AuthenticationFactoryTests.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,9 +365,11 @@ public void AppServiceManagedIdentity()
365365
{
366366
AzureSessionInitializer.InitializeAzureSession();
367367
var tenant = Guid.NewGuid().ToString();
368+
var userId = "MSI@2";
368369
var environment = AzureEnvironment.PublicEnvironments["AzureCloud"];
369370
var account = new AzureAccount
370371
{
372+
Id = userId,
371373
Type = AzureAccount.AccountType.ManagedService
372374
};
373375
const string resource = @"https://management.azure.com/";
@@ -445,9 +447,11 @@ public void AppServiceManagedIdentityWithDataPlane()
445447
{
446448
AzureSessionInitializer.InitializeAzureSession();
447449
var tenant = Guid.NewGuid().ToString();
450+
var userId = "MSI@2";
448451
var environment = AzureEnvironment.PublicEnvironments["AzureCloud"];
449452
var account = new AzureAccount
450453
{
454+
Id = userId,
451455
Type = AzureAccount.AccountType.ManagedService
452456
};
453457
const string resource = @"https://vault.azure.com/";
@@ -484,9 +488,11 @@ public void AppServiceManagedIdentityWithServiceManagement()
484488
{
485489
AzureSessionInitializer.InitializeAzureSession();
486490
var tenant = Guid.NewGuid().ToString();
491+
var userId = "MSI@2";
487492
var environment = AzureEnvironment.PublicEnvironments["AzureCloud"];
488493
var account = new AzureAccount
489494
{
495+
Id = userId,
490496
Type = AzureAccount.AccountType.ManagedService
491497
};
492498
const string resource = @"https://management.azure.com/";

src/Accounts/Authentication/Authentication/ManagedServiceAccessTokenBase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public abstract class ManagedServiceAccessTokenBase<TManagedServiceTokenInfo> :
3434

3535
protected ManagedServiceAccessTokenBase(IAzureAccount account, IAzureEnvironment environment, string resourceId, string tenant = "Common")
3636
{
37-
if (!account.IsPropertySet(AzureAccount.Property.MSILoginUri))
37+
if (string.IsNullOrWhiteSpace(account?.Id) || !account.IsPropertySet(AzureAccount.Property.MSILoginUri))
3838
{
3939
throw new ArgumentNullException(nameof(account));
4040
}

0 commit comments

Comments
 (0)