diff --git a/Snowflake.Data.Tests/UnitTests/SFSessionPropertyTest.cs b/Snowflake.Data.Tests/UnitTests/SFSessionPropertyTest.cs index 183788e90..a57a9fb74 100644 --- a/Snowflake.Data.Tests/UnitTests/SFSessionPropertyTest.cs +++ b/Snowflake.Data.Tests/UnitTests/SFSessionPropertyTest.cs @@ -1,4 +1,4 @@ -/* +/* * Copyright (c) 2019 Snowflake Computing Inc. All rights reserved. */ @@ -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 ConnectionStringTestCases() { string defAccount = "testaccount"; diff --git a/Snowflake.Data/Core/Session/SFSessionProperty.cs b/Snowflake.Data/Core/Session/SFSessionProperty.cs index 226c75cb1..bfbe71a2a 100644 --- a/Snowflake.Data/Core/Session/SFSessionProperty.cs +++ b/Snowflake.Data/Core/Session/SFSessionProperty.cs @@ -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 @@ -290,6 +291,11 @@ internal static SFSessionProperties ParseConnectionString(string connectionStrin return properties; } + internal static string ResolveConnectionAreaMessage(string host) => + host.EndsWith(".cn", StringComparison.InvariantCultureIgnoreCase) + ? "Connecting to CHINA Snowflake domain" + : "Connecting to GLOBAL Snowflake domain"; + private static void ValidateAuthenticator(SFSessionProperties properties) { var knownAuthenticators = new[] {