From 275304bc3ec34418012e15734e920809db000448 Mon Sep 17 00:00:00 2001 From: WaelAbuSeada Date: Fri, 1 Nov 2024 10:33:56 -0700 Subject: [PATCH] Improve error message and fix test --- .../App/Azure Key Vault/src/AzureKeyVaultImpl.Codeunit.al | 4 ++-- .../Test/Azure Key Vault/src/AzureKeyVaultTest.Codeunit.al | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/System Application/App/Azure Key Vault/src/AzureKeyVaultImpl.Codeunit.al b/src/System Application/App/Azure Key Vault/src/AzureKeyVaultImpl.Codeunit.al index 589c1123d6..7813e6c612 100644 --- a/src/System Application/App/Azure Key Vault/src/AzureKeyVaultImpl.Codeunit.al +++ b/src/System Application/App/Azure Key Vault/src/AzureKeyVaultImpl.Codeunit.al @@ -39,7 +39,7 @@ codeunit 2202 "Azure Key Vault Impl." Secret := GetSecretFromClient(SecretName); if Secret = '' then - Error(MissingSecretErr); + Error(MissingSecretErr, SecretName); end; [NonDebuggable] @@ -48,7 +48,7 @@ codeunit 2202 "Azure Key Vault Impl." Secret := GetSecretFromClient(SecretName); if Secret.IsEmpty() then - Error(MissingSecretErr); + Error(MissingSecretErr, SecretName); end; [NonDebuggable] diff --git a/src/System Application/Test/Azure Key Vault/src/AzureKeyVaultTest.Codeunit.al b/src/System Application/Test/Azure Key Vault/src/AzureKeyVaultTest.Codeunit.al index 2a1fd4d7fb..a59e6ef80a 100644 --- a/src/System Application/Test/Azure Key Vault/src/AzureKeyVaultTest.Codeunit.al +++ b/src/System Application/Test/Azure Key Vault/src/AzureKeyVaultTest.Codeunit.al @@ -23,6 +23,7 @@ codeunit 135212 "Azure Key Vault Test" var Assert: Codeunit "Library Assert"; KeyVaultNotInitializedTxt: Label 'Azure key vault has not been set up'; + MissingSecretErr: Label '%1 is either missing or empty', Locked = true; [Test] [TransactionModel(TransactionModel::AutoRollback)] @@ -95,11 +96,12 @@ codeunit 135212 "Azure Key Vault Test" // [GIVEN] A configured Azure Key Vault MockAzureKeyvaultSecretProvider := MockAzureKeyvaultSecretProvider.MockAzureKeyVaultSecretProvider(); + MockAzureKeyvaultSecretProvider.AddSecretMapping('some-secret', 'SecretFromKeyVault'); AzureKeyVaultTestLibrary.SetAzureKeyVaultSecretProvider(MockAzureKeyvaultSecretProvider); - AzureKeyVaultTestLibrary.ClearSecrets(); // [WHEN] The key vault is called with an unknown key asserterror AzureKeyVault.GetAzureKeyVaultSecret('somekeythatdoesnotexist', Secret); + Assert.ExpectedError(StrSubstNo(MissingSecretErr, 'somekeythatdoesnotexist')); end; [Test]