Skip to content

Commit

Permalink
Added code coverage to refactored code.
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-jmartinezramirez committed Mar 18, 2024
1 parent 1137cf8 commit f854bed
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
33 changes: 33 additions & 0 deletions Snowflake.Data.Tests/UnitTests/SFSessionPropertyTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

namespace Snowflake.Data.Tests.UnitTests
{
using System;

class SFSessionPropertyTest
{

Expand Down Expand Up @@ -135,6 +137,36 @@ public static IEnumerable<TestCase> ConnectionStringTestCases()
}
};

var testCaseWithEmptyUserAndPassword = new TestCase()
{
ConnectionString = $"ACCOUNT={defAccount};USER=;PASSWORD=",
ExpectedProperties = new SFSessionProperties()
{
{ SFSessionProperty.ACCOUNT, defAccount },
{ SFSessionProperty.USER, string.Empty },
{ SFSessionProperty.HOST, defHost },
{ SFSessionProperty.AUTHENTICATOR, defAuthenticator },
{ SFSessionProperty.SCHEME, defScheme },
{ SFSessionProperty.CONNECTION_TIMEOUT, defConnectionTimeout },
{ SFSessionProperty.PASSWORD, string.Empty },
{ SFSessionProperty.PORT, defPort },
{ SFSessionProperty.VALIDATE_DEFAULT_PARAMETERS, "true" },
{ SFSessionProperty.USEPROXY, "false" },
{ SFSessionProperty.INSECUREMODE, "false" },
{ SFSessionProperty.DISABLERETRY, "false" },
{ SFSessionProperty.FORCERETRYON404, "false" },
{ SFSessionProperty.CLIENT_SESSION_KEEP_ALIVE, "false" },
{ SFSessionProperty.FORCEPARSEERROR, "false" },
{ SFSessionProperty.BROWSER_RESPONSE_TIMEOUT, defBrowserResponseTime },
{ SFSessionProperty.RETRY_TIMEOUT, defRetryTimeout },
{ SFSessionProperty.MAXHTTPRETRIES, defMaxHttpRetries },
{ SFSessionProperty.INCLUDERETRYREASON, defIncludeRetryReason },
{ SFSessionProperty.DISABLEQUERYCONTEXTCACHE, defDisableQueryContextCache },
{ SFSessionProperty.DISABLE_CONSOLE_LOGIN, defDisableConsoleLogin },
{ SFSessionProperty.ALLOWUNDERSCORESINHOST, defAllowUnderscoresInHost }
}
};

var warehouseWithSpaces = "\"warehouse test\"";
var dbWithQuotes = "\"testdb\"";
var testCaseWithWrappedValuesWithQuotesAndAllowSpaces = new TestCase()
Expand Down Expand Up @@ -472,6 +504,7 @@ public static IEnumerable<TestCase> ConnectionStringTestCases()
return new TestCase[]
{
simpleTestCase,
testCaseWithEmptyUserAndPassword,
testCaseWithWrappedValuesWithQuotesAndAllowSpaces,
testCaseWithBrowserResponseTimeout,
testCaseWithProxySettings,
Expand Down
7 changes: 6 additions & 1 deletion Snowflake.Data/Core/Session/SFSessionProperty.cs
Original file line number Diff line number Diff line change
Expand Up @@ -293,9 +293,14 @@ private static void ProcessPropertySpecialCases(string connectionString, SFSessi
case "USER":
case "PASSWORD":
{

var sessionProperty = (SFSessionProperty)Enum.Parse(
typeof(SFSessionProperty), propertyName);
properties.TryAdd(sessionProperty, string.Empty);
if (!properties.ContainsKey(sessionProperty))
{
properties.Add(sessionProperty, "");
}

break;
}
}
Expand Down

0 comments on commit f854bed

Please sign in to comment.