Skip to content

Commit 9736edd

Browse files
SNOW-1526509 Log connecting area (#992)
### Description SNOW-1526509 Log connecting area ### Checklist - [x] Code compiles correctly - [x] Code is formatted according to [Coding Conventions](../blob/master/CodingConventions.md) - [x] Created tests which fail without the change (if possible) - [x] All tests passing (`dotnet test`) - [x] Extended the README / documentation, if necessary - [x] Provide JIRA issue id (if possible) or GitHub issue id in PR name
1 parent bc329ab commit 9736edd

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

Snowflake.Data.Tests/UnitTests/SFSessionPropertyTest.cs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*
1+
/*
22
* Copyright (c) 2019 Snowflake Computing Inc. All rights reserved.
33
*/
44

@@ -154,6 +154,18 @@ public void TestValidateDisableSamlUrlCheckProperty(string expectedDisableSamlUr
154154
Assert.AreEqual(expectedDisableSamlUrlCheck, properties[SFSessionProperty.DISABLE_SAML_URL_CHECK]);
155155
}
156156

157+
[Test]
158+
[TestCase("account.snowflakecomputing.cn", "Connecting to CHINA Snowflake domain")]
159+
[TestCase("account.snowflakecomputing.com", "Connecting to GLOBAL Snowflake domain")]
160+
public void TestResolveConnectionArea(string host, string expectedMessage)
161+
{
162+
// act
163+
var message = SFSessionProperties.ResolveConnectionAreaMessage(host);
164+
165+
// assert
166+
Assert.AreEqual(expectedMessage, message);
167+
}
168+
157169
public static IEnumerable<TestCase> ConnectionStringTestCases()
158170
{
159171
string defAccount = "testaccount";

Snowflake.Data/Core/Session/SFSessionProperty.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,7 @@ internal static SFSessionProperties ParseConnectionString(string connectionStrin
281281
properties.Add(SFSessionProperty.HOST, hostName);
282282
logger.Info($"Compose host name: {hostName}");
283283
}
284+
logger.Info(ResolveConnectionAreaMessage(properties[SFSessionProperty.HOST]));
284285

285286
// Trim the account name to remove the region and cloud platform if any were provided
286287
// because the login request data does not expect region and cloud information to be
@@ -290,6 +291,11 @@ internal static SFSessionProperties ParseConnectionString(string connectionStrin
290291
return properties;
291292
}
292293

294+
internal static string ResolveConnectionAreaMessage(string host) =>
295+
host.EndsWith(".cn", StringComparison.InvariantCultureIgnoreCase)
296+
? "Connecting to CHINA Snowflake domain"
297+
: "Connecting to GLOBAL Snowflake domain";
298+
293299
private static void ValidateAuthenticator(SFSessionProperties properties)
294300
{
295301
var knownAuthenticators = new[] {

0 commit comments

Comments
 (0)