From 5578763dc0acf2a96f37ab8ed6f541c99e1de324 Mon Sep 17 00:00:00 2001 From: Junjie Gao Date: Thu, 28 Mar 2024 13:59:05 +0800 Subject: [PATCH] fix: update code Signed-off-by: Junjie Gao --- .../KeyVault/CredentialsTests.cs | 2 +- .../KeyVault/Credentials.cs | 28 +++++++++---------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/Notation.Plugin.AzureKeyVault.Tests/KeyVault/CredentialsTests.cs b/Notation.Plugin.AzureKeyVault.Tests/KeyVault/CredentialsTests.cs index 8da746e..b9ab909 100644 --- a/Notation.Plugin.AzureKeyVault.Tests/KeyVault/CredentialsTests.cs +++ b/Notation.Plugin.AzureKeyVault.Tests/KeyVault/CredentialsTests.cs @@ -39,7 +39,7 @@ public void GetCredentials_WithPluginConfig_ReturnsExpectedCredential() // Arrange var pluginConfig = new Dictionary { - { "credential_type", "default" } + { "authentication_method", "default" } }; // Act diff --git a/Notation.Plugin.AzureKeyVault/KeyVault/Credentials.cs b/Notation.Plugin.AzureKeyVault/KeyVault/Credentials.cs index b564aac..452e80d 100644 --- a/Notation.Plugin.AzureKeyVault/KeyVault/Credentials.cs +++ b/Notation.Plugin.AzureKeyVault/KeyVault/Credentials.cs @@ -7,29 +7,29 @@ namespace Notation.Plugin.AzureKeyVault.Credential public class Credentials { /// - /// Credential type key name in plugin config. + /// authentication method key name in plugin config. /// - public const string CredentialTypeKey = "credential_type"; + public const string AuthenticationMethod = "authentication_method"; /// /// Default credential name. /// - public const string DefaultCredentialName = "default"; + public const string DefaultAuthentication = "default"; /// /// Environment credential name. /// - public const string EnvironmentCredentialName = "environment"; + public const string EnvironmentAuthentication = "environment"; /// /// Workload identity credential name. /// - public const string WorkloadIdentityCredentialName = "workloadidentity"; + public const string WorkloadIdentityAuthentication = "workloadidentity"; /// /// Managed identity credential name. /// - public const string ManagedIdentityCredentialName = "managedidentity"; + public const string ManagedIdentityAuthentication = "managedidentity"; /// /// Azure CLI credential name. /// - public const string AzureCliCredentialName = "azurecli"; + public const string AzureCliAuthentication = "azurecli"; /// /// Get the credential based on the credential type. @@ -39,15 +39,15 @@ public static TokenCredential GetCredentials(string credentialType) credentialType = credentialType.ToLower(); switch (credentialType) { - case DefaultCredentialName: + case DefaultAuthentication: return new DefaultAzureCredential(); - case EnvironmentCredentialName: + case EnvironmentAuthentication: return new EnvironmentCredential(); - case WorkloadIdentityCredentialName: + case WorkloadIdentityAuthentication: return new WorkloadIdentityCredential(); - case ManagedIdentityCredentialName: + case ManagedIdentityAuthentication: return new ManagedIdentityCredential(); - case AzureCliCredentialName: + case AzureCliAuthentication: return new AzureCliCredential(); default: throw new ValidationException($"Invalid credential key: {credentialType}"); @@ -59,8 +59,8 @@ public static TokenCredential GetCredentials(string credentialType) /// public static TokenCredential GetCredentials(Dictionary? pluginConfig) { - var credentialName = pluginConfig?.GetValueOrDefault(CredentialTypeKey, DefaultCredentialName) ?? - DefaultCredentialName; + var credentialName = pluginConfig?.GetValueOrDefault(AuthenticationMethod, DefaultAuthentication) ?? + DefaultAuthentication; return GetCredentials(credentialName); } }