Skip to content

Commit

Permalink
fix dns names with underscore
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-bculberson committed Dec 14, 2023
1 parent 3ccdab3 commit a715a99
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
31 changes: 30 additions & 1 deletion Snowflake.Data.Tests/UnitTests/SFSessionPropertyTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,34 @@ public static IEnumerable<TestCase> ConnectionStringTestCases()
{ SFSessionProperty.DISABLEQUERYCONTEXTCACHE, defDisableQueryContextCache }
}
};
var underscoredAccount = $"prefix_{defAccount}";
var testCaseUnderscoredAccountName = new TestCase()
{
ConnectionString = $"ACCOUNT={underscoredAccount};USER={defUser};PASSWORD={defPassword};",
ExpectedProperties = new SFSessionProperties()
{
{ SFSessionProperty.ACCOUNT, underscoredAccount},
{ SFSessionProperty.USER, defUser },
{ SFSessionProperty.HOST, $"prefix-{underscoredAccount}.snowflakecomputing.com" },
{ SFSessionProperty.AUTHENTICATOR, defAuthenticator },
{ SFSessionProperty.SCHEME, defScheme },
{ SFSessionProperty.CONNECTION_TIMEOUT, defConnectionTimeout },
{ SFSessionProperty.PASSWORD, defPassword },
{ 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 }
}
};
return new TestCase[]
{
simpleTestCase,
Expand All @@ -314,7 +342,8 @@ public static IEnumerable<TestCase> ConnectionStringTestCases()
testCaseWithFileTransferMaxBytesInMemory,
testCaseWithIncludeRetryReason,
testCaseWithDisableQueryContextCache,
testCaseComplicatedAccountName
testCaseComplicatedAccountName,
testCaseUnderscoredAccountName
};
}

Expand Down
3 changes: 2 additions & 1 deletion Snowflake.Data/Core/Session/SFSessionProperty.cs
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,8 @@ internal static SFSessionProperties parseConnectionString(String connectionStrin
if (!properties.ContainsKey(SFSessionProperty.HOST) ||
(0 == properties[SFSessionProperty.HOST].Length))
{
string hostName = String.Format("{0}.snowflakecomputing.com", properties[SFSessionProperty.ACCOUNT]);
string compliantAccountName = properties[SFSessionProperty.ACCOUNT].Replace('_','-');
string hostName = String.Format("{0}.snowflakecomputing.com", compliantAccountName);
// Remove in case it's here but empty
properties.Remove(SFSessionProperty.HOST);
properties.Add(SFSessionProperty.HOST, hostName);
Expand Down

0 comments on commit a715a99

Please sign in to comment.