From 5fa469100e235ce7d252e2d2253ae859079fb278 Mon Sep 17 00:00:00 2001 From: Krzysztof Nozderko Date: Fri, 12 Jul 2024 14:09:23 +0000 Subject: [PATCH 1/2] SNOW-1526509 Log connecting area --- .../UnitTests/SFSessionPropertyTest.cs | 14 +++++++++++++- Snowflake.Data/Core/Session/SFSessionProperty.cs | 6 ++++++ 2 files changed, 19 insertions(+), 1 deletion(-) 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..3af0ac995 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(".snowflakecomputing.cn", StringComparison.InvariantCultureIgnoreCase) + ? "Connecting to CHINA Snowflake domain" + : "Connecting to GLOBAL Snowflake domain"; + private static void ValidateAuthenticator(SFSessionProperties properties) { var knownAuthenticators = new[] { From e87cf23da38ec4c0f018c6ce8b45cc6ea6f0fa16 Mon Sep 17 00:00:00 2001 From: Krzysztof Nozderko Date: Mon, 15 Jul 2024 10:07:17 +0000 Subject: [PATCH 2/2] recognise area by the very suffix --- Snowflake.Data/Core/Session/SFSessionProperty.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Snowflake.Data/Core/Session/SFSessionProperty.cs b/Snowflake.Data/Core/Session/SFSessionProperty.cs index 3af0ac995..bfbe71a2a 100644 --- a/Snowflake.Data/Core/Session/SFSessionProperty.cs +++ b/Snowflake.Data/Core/Session/SFSessionProperty.cs @@ -292,7 +292,7 @@ internal static SFSessionProperties ParseConnectionString(string connectionStrin } internal static string ResolveConnectionAreaMessage(string host) => - host.EndsWith(".snowflakecomputing.cn", StringComparison.InvariantCultureIgnoreCase) + host.EndsWith(".cn", StringComparison.InvariantCultureIgnoreCase) ? "Connecting to CHINA Snowflake domain" : "Connecting to GLOBAL Snowflake domain";