Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SNOW-1526509 Log connecting area #992

Merged
merged 2 commits into from
Jul 15, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion Snowflake.Data.Tests/UnitTests/SFSessionPropertyTest.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*
/*
* Copyright (c) 2019 Snowflake Computing Inc. All rights reserved.
*/

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

[Test]
[TestCase("account.snowflakecomputing.cn", "Connecting to CHINA Snowflake domain")]
[TestCase("account.snowflakecomputing.com", "Connecting to GLOBAL Snowflake domain")]
public void TestResolveConnectionArea(string host, string expectedMessage)
{
// act
var message = SFSessionProperties.ResolveConnectionAreaMessage(host);

// assert
Assert.AreEqual(expectedMessage, message);
}

public static IEnumerable<TestCase> ConnectionStringTestCases()
{
string defAccount = "testaccount";
Expand Down
6 changes: 6 additions & 0 deletions Snowflake.Data/Core/Session/SFSessionProperty.cs
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,7 @@ internal static SFSessionProperties ParseConnectionString(string connectionStrin
properties.Add(SFSessionProperty.HOST, hostName);
logger.Info($"Compose host name: {hostName}");
}
logger.Info(ResolveConnectionAreaMessage(properties[SFSessionProperty.HOST]));

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

internal static string ResolveConnectionAreaMessage(string host) =>
host.EndsWith(".snowflakecomputing.cn", StringComparison.InvariantCultureIgnoreCase)
sfc-gh-knozderko marked this conversation as resolved.
Show resolved Hide resolved
? "Connecting to CHINA Snowflake domain"
: "Connecting to GLOBAL Snowflake domain";
sfc-gh-dprzybysz marked this conversation as resolved.
Show resolved Hide resolved

private static void ValidateAuthenticator(SFSessionProperties properties)
{
var knownAuthenticators = new[] {
Expand Down
Loading