Skip to content

Commit

Permalink
Improve error message and fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
WaelAbuSeada authored and WaelAbuSeada committed Nov 1, 2024
1 parent 5c9a53e commit 275304b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ codeunit 2202 "Azure Key Vault Impl."
Secret := GetSecretFromClient(SecretName);

if Secret = '' then
Error(MissingSecretErr);
Error(MissingSecretErr, SecretName);
end;

[NonDebuggable]
Expand All @@ -48,7 +48,7 @@ codeunit 2202 "Azure Key Vault Impl."
Secret := GetSecretFromClient(SecretName);

if Secret.IsEmpty() then
Error(MissingSecretErr);
Error(MissingSecretErr, SecretName);
end;

[NonDebuggable]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down Expand Up @@ -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]
Expand Down

0 comments on commit 275304b

Please sign in to comment.