From dc93ecf3ce4212e69218bd1624ecc9e9a6270871 Mon Sep 17 00:00:00 2001 From: Jesse Squire Date: Fri, 4 Sep 2020 11:01:12 -0400 Subject: [PATCH] [Azure.Core TestFramework] Fix Required Optional Environment Variable The focus of these changes is to bypass the attempt to santitize an optional environment variable when no value was present. Previously, if the variable was not read, sanitizing would result in an exception. --- .../src/TestEnvironment.cs | 15 ++++++++++---- .../Azure.Core/tests/TestEnvironmentTests.cs | 20 ++++++++++++++++++- 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/sdk/core/Azure.Core.TestFramework/src/TestEnvironment.cs b/sdk/core/Azure.Core.TestFramework/src/TestEnvironment.cs index c2af55787c28..948fbc9249c2 100644 --- a/sdk/core/Azure.Core.TestFramework/src/TestEnvironment.cs +++ b/sdk/core/Azure.Core.TestFramework/src/TestEnvironment.cs @@ -177,10 +177,6 @@ protected string GetRecordedOptionalVariable(string name, Action { // To make NUnit happy @@ -114,8 +131,9 @@ public MockTestEnvironment(): base("core") public string Base64Secret => GetRecordedVariable("Base64Secret", option => option.IsSecret(SanitizedValue.Base64)); public string DefaultSecret => GetRecordedVariable("DefaultSecret", option => option.IsSecret(SanitizedValue.Default)); public string CustomSecret => GetRecordedVariable("CustomSecret", option => option.IsSecret("Custom")); + public string MissingOptionalSecret => GetRecordedOptionalVariable("MissingOptionalSecret", option => option.IsSecret("INVALID")); public string ConnectionStringWithSecret => GetRecordedVariable("ConnectionStringWithSecret", option => option.HasSecretConnectionStringParameter("key")); } } -} \ No newline at end of file +}