diff --git a/Snowflake.Data.Tests/UnitTests/Session/SFHttpClientPropertiesTest.cs b/Snowflake.Data.Tests/UnitTests/Session/SFHttpClientPropertiesTest.cs index ea6deb5ca..72421f588 100644 --- a/Snowflake.Data.Tests/UnitTests/Session/SFHttpClientPropertiesTest.cs +++ b/Snowflake.Data.Tests/UnitTests/Session/SFHttpClientPropertiesTest.cs @@ -15,11 +15,11 @@ namespace Snowflake.Data.Tests.UnitTests.Session public class SFHttpClientPropertiesTest { [Test] - public void ShouldConvertToMapOnly2Properties( + public void TestConvertToMapOnly2Properties( [Values(true, false)] bool validateDefaultParameters, [Values(true, false)] bool clientSessionKeepAlive) { - // given + // arrange var proxyProperties = new SFSessionHttpClientProxyProperties() { proxyHost = "localhost", @@ -41,19 +41,52 @@ public void ShouldConvertToMapOnly2Properties( proxyProperties = proxyProperties }; - // when + // act var parameterMap = properties.ToParameterMap(); - // then + // assert Assert.AreEqual(2, parameterMap.Count); Assert.AreEqual(validateDefaultParameters, parameterMap[SFSessionParameter.CLIENT_VALIDATE_DEFAULT_PARAMETERS]); Assert.AreEqual(clientSessionKeepAlive, parameterMap[SFSessionParameter.CLIENT_SESSION_KEEP_ALIVE]); } [Test] - public void ShouldBuildHttpClientConfig() + public void TestBuildHttpClientConfig() + { + // arrange + var properties = RandomSFSessionHttpClientProperties(); + + // act + var config = properties.BuildHttpClientConfig(); + + // assert + Assert.AreEqual(!properties.insecureMode, config.CrlCheckEnabled); + Assert.AreEqual(properties.proxyProperties.proxyHost, config.ProxyHost); + Assert.AreEqual(properties.proxyProperties.proxyPort, config.ProxyPort); + Assert.AreEqual(properties.proxyProperties.proxyUser, config.ProxyUser); + Assert.AreEqual(properties.proxyProperties.proxyPassword, config.ProxyPassword); + Assert.AreEqual(properties.proxyProperties.nonProxyHosts, config.NoProxyList); + Assert.AreEqual(properties.disableRetry, config.DisableRetry); + Assert.AreEqual(properties.forceRetryOn404, config.ForceRetryOn404); + Assert.AreEqual(properties.maxHttpRetries, config.MaxHttpRetries); + } + + [Test] + public void TestCrlCheckEnabledToBeOppositeInsecureMode([Values] bool insecureMode) + { + // arrange + var properties = RandomSFSessionHttpClientProperties(); + properties.insecureMode = insecureMode; + + // act + var config = properties.BuildHttpClientConfig(); + + // assert + Assert.AreEqual(!insecureMode, config.CrlCheckEnabled); + } + + private SFSessionHttpClientProperties RandomSFSessionHttpClientProperties() { - // given var proxyProperties = new SFSessionHttpClientProxyProperties() { proxyHost = TestDataGenarator.NextAlphaNumeric(), @@ -62,7 +95,7 @@ public void ShouldBuildHttpClientConfig() proxyPassword = TestDataGenarator.NextAlphaNumeric(), proxyUser = TestDataGenarator.NextAlphaNumeric() }; - var properties = new SFSessionHttpClientProperties() + return new SFSessionHttpClientProperties() { validateDefaultParameters = TestDataGenarator.NextBool(), clientSessionKeepAlive = TestDataGenarator.NextBool(), @@ -74,26 +107,12 @@ public void ShouldBuildHttpClientConfig() maxHttpRetries = TestDataGenarator.NextInt(0, 15), proxyProperties = proxyProperties }; - - // when - var config = properties.BuildHttpClientConfig(); - - // then - Assert.AreEqual(properties.insecureMode, config.CrlCheckEnabled); - Assert.AreEqual(properties.proxyProperties.proxyHost, config.ProxyHost); - Assert.AreEqual(properties.proxyProperties.proxyPort, config.ProxyPort); - Assert.AreEqual(properties.proxyProperties.proxyUser, config.ProxyUser); - Assert.AreEqual(properties.proxyProperties.proxyPassword, config.ProxyPassword); - Assert.AreEqual(properties.proxyProperties.nonProxyHosts, config.NoProxyList); - Assert.AreEqual(properties.disableRetry, config.DisableRetry); - Assert.AreEqual(properties.forceRetryOn404, config.ForceRetryOn404); - Assert.AreEqual(properties.maxHttpRetries, config.MaxHttpRetries); } [Test, TestCaseSource(nameof(PropertiesProvider))] - public void ShouldExtractProperties(PropertiesTestCase testCase) + public void TestExtractProperties(PropertiesTestCase testCase) { - // given + // arrange var proxyExtractorMock = new Moq.Mock(); var extractor = new SFSessionHttpClientProperties.Extractor(proxyExtractorMock.Object); var properties = SFSessionProperties.parseConnectionString(testCase.conectionString, null); @@ -102,11 +121,11 @@ public void ShouldExtractProperties(PropertiesTestCase testCase) .Setup(e => e.ExtractProperties(properties)) .Returns(proxyProperties); - // when + // act var extractedProperties = extractor.ExtractProperties(properties); extractedProperties.CheckPropertiesAreValid(); - // then + // assert Assert.AreEqual(testCase.expectedProperties.validateDefaultParameters, extractedProperties.validateDefaultParameters); Assert.AreEqual(testCase.expectedProperties.clientSessionKeepAlive, extractedProperties.clientSessionKeepAlive); Assert.AreEqual(testCase.expectedProperties.timeoutInSec, extractedProperties.timeoutInSec); diff --git a/Snowflake.Data/Core/Session/SFSessionHttpClientProperties.cs b/Snowflake.Data/Core/Session/SFSessionHttpClientProperties.cs index b7466a362..f129de25a 100644 --- a/Snowflake.Data/Core/Session/SFSessionHttpClientProperties.cs +++ b/Snowflake.Data/Core/Session/SFSessionHttpClientProperties.cs @@ -75,7 +75,7 @@ internal TimeSpan TimeoutDuration() internal HttpClientConfig BuildHttpClientConfig() { return new HttpClientConfig( - insecureMode, + !insecureMode, proxyProperties.proxyHost, proxyProperties.proxyPort, proxyProperties.proxyUser,