diff --git a/Snowflake.Data.Tests/IntegrationTests/SFConnectionIT.cs b/Snowflake.Data.Tests/IntegrationTests/SFConnectionIT.cs index da4628588..32aacdf31 100644 --- a/Snowflake.Data.Tests/IntegrationTests/SFConnectionIT.cs +++ b/Snowflake.Data.Tests/IntegrationTests/SFConnectionIT.cs @@ -1543,6 +1543,8 @@ public void TestInvalidProxySettingFromConnectionString() [Test] [TestCase("*")] [TestCase("*{0}*")] + [TestCase("^*{0}*")] + [TestCase("*{0}*$")] [TestCase("^*{0}*$")] [TestCase("^nonmatch*{0}$|*")] [TestCase("*a*", "a")] @@ -1576,18 +1578,10 @@ public void TestNonProxyHostShouldNotBypassProxyServer(string regexHost, string var proxyHostForConnection = proxyHost ?? "proxyserverhost"; conn.ConnectionString = $"{ConnectionString}connection_timeout=5;USEPROXY=true;PROXYHOST={proxyHostForConnection};NONPROXYHOSTS={nonProxyHosts};PROXYPORT=3128;"; - try - { - conn.Open(); - //Assert.Fail(); - } - catch (SnowflakeDbException e) - { - // Expected - s_logger.Debug("Failed opening connection ", e); - Assert.AreEqual(270001, e.ErrorCode); //Internal error - AssertIsConnectionFailure(e); - } + var exception = Assert.Throws(() => conn.Open()); + s_logger.Debug("Failed opening connection ", exception); + Assert.AreEqual(270001, exception.ErrorCode); + AssertIsConnectionFailure(exception); } } diff --git a/Snowflake.Data/Core/HttpUtil.cs b/Snowflake.Data/Core/HttpUtil.cs index a234c3e3d..6ed9395ae 100755 --- a/Snowflake.Data/Core/HttpUtil.cs +++ b/Snowflake.Data/Core/HttpUtil.cs @@ -188,11 +188,11 @@ internal HttpMessageHandler SetupCustomHttpHandler(HttpClientConfig config) entry = entry.Replace(".", "[.]"); // * -> .* because * is a quantifier and need a char or group to apply to entry = entry.Replace("*", ".*"); - - if (!entry.StartsWith("^") || !entry.EndsWith("$")) - { - entry = $"^{entry}$"; - } + + entry = entry.StartsWith("^") ? entry : $"^{entry}"; + + entry = entry.EndsWith("$") ? entry : $"{entry}$"; + // Replace with the valid entry syntax bypassList[i] = entry;