diff --git a/Directory.Packages.props b/Directory.Packages.props index d2e7270..ed87bd9 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -5,21 +5,21 @@ - - - - - - - - - - - - + + + + + + + + + + + + - - + + \ No newline at end of file diff --git a/src/ColumnEncryptor/Services/AzureKeyVaultClient.cs b/src/ColumnEncryptor/Services/AzureKeyVaultClient.cs index 35893cc..8b05b35 100644 --- a/src/ColumnEncryptor/Services/AzureKeyVaultClient.cs +++ b/src/ColumnEncryptor/Services/AzureKeyVaultClient.cs @@ -32,7 +32,9 @@ public AzureKeyVaultClient( TokenCredential credential = azureOptions.AuthMethod switch { AzureAuthMethod.DefaultAzureCredential => new DefaultAzureCredential(), - AzureAuthMethod.ManagedIdentity => new ManagedIdentityCredential(azureOptions.ClientId), + AzureAuthMethod.ManagedIdentity => string.IsNullOrWhiteSpace(azureOptions.ClientId) + ? new ManagedIdentityCredential(ManagedIdentityId.SystemAssigned) + : new ManagedIdentityCredential(ManagedIdentityId.FromUserAssignedClientId(azureOptions.ClientId.Trim())), AzureAuthMethod.ServicePrincipal => new ClientSecretCredential( azureOptions.TenantId, azureOptions.ClientId, diff --git a/tests/ColumnEncryptor.Tests/EntityFrameworkIntegrationTests.cs b/tests/ColumnEncryptor.Tests/EntityFrameworkIntegrationTests.cs index d08c02d..5c9b9bd 100644 --- a/tests/ColumnEncryptor.Tests/EntityFrameworkIntegrationTests.cs +++ b/tests/ColumnEncryptor.Tests/EntityFrameworkIntegrationTests.cs @@ -32,8 +32,7 @@ public class EntityFrameworkIntegrationTests public async Task OneTimeSetUp() { // Start HashiCorp Vault container - _vaultContainer = new ContainerBuilder() - .WithImage(VaultImage) + _vaultContainer = new ContainerBuilder(VaultImage) .WithCleanUp(true) .WithName($"vault-test-{Guid.NewGuid():N}") // Bind the container's Vault port to a random free host port to avoid collisions @@ -57,7 +56,7 @@ public async Task OneTimeSetUp() await WaitForVaultHealthy(_vaultUrl); // Start SQL Server container - _sqlContainer = new MsSqlBuilder() + _sqlContainer = new MsSqlBuilder("mcr.microsoft.com/mssql/server:2022-CU14-ubuntu-22.04") .WithPassword(SqlServerPassword) .WithCleanUp(true) .WithName($"sql-test-{Guid.NewGuid():N}") diff --git a/tests/ColumnEncryptor.Tests/HashiCorpTests.cs b/tests/ColumnEncryptor.Tests/HashiCorpTests.cs index a4baac8..06a1442 100644 --- a/tests/ColumnEncryptor.Tests/HashiCorpTests.cs +++ b/tests/ColumnEncryptor.Tests/HashiCorpTests.cs @@ -23,8 +23,7 @@ public class HashiCorpTests public async Task OneTimeSetUp() { // Start HashiCorp Vault container - _vaultContainer = new ContainerBuilder() - .WithImage(VaultImage) + _vaultContainer = new ContainerBuilder(VaultImage) .WithCleanUp(true) .WithName($"vault-test-{Guid.NewGuid():N}") // Bind the container's Vault port to a random free host port to avoid collisions