public void AuthInfo_Ctor_AccountWithUnderscore() { var authInfo = new AuthInfo("user", "pw", "account_with_undescore"); var settings = new SnowflakeClientSettings(authInfo); Assert.AreEqual("account-with-undescore.snowflakecomputing.com", settings.UrlInfo.Host); }
public void AuthInfo_Ctor_Unique_Regions(string region) { var authInfo = new AuthInfo("user", "pw", "account", region); var settings = new SnowflakeClientSettings(authInfo); Assert.AreEqual($"account.{region}.snowflakecomputing.com", settings.UrlInfo.Host); }
public void UrlInfo_Explicit_Host_Account_WithUnderscore() { var authInfo = new AuthInfo("user", "pw", "account"); var urlInfo = new UrlInfo("account_with_undescore.snowflakecomputing.com"); var settings = new SnowflakeClientSettings(authInfo, null, urlInfo); Assert.AreEqual($"account-with-undescore.snowflakecomputing.com", settings.UrlInfo.Host); }
public void UrlInfo_Explicit_Host() { var authInfo = new AuthInfo("user", "pw", "account-auth"); var urlInfo = new UrlInfo("account-url.snowflakecomputing.com"); var settings = new SnowflakeClientSettings(authInfo, null, urlInfo); Assert.AreEqual("account-url.snowflakecomputing.com", settings.UrlInfo.Host); }
/// <summary> /// Creates new Snowflake client. /// </summary> /// <param name="settings">Client settings to initialize new session.</param> public SnowflakeClient(SnowflakeClientSettings settings) { ValidateClientSettings(settings); _clientSettings = settings; _restClient = new RestClient(); _requestBuilder = new RequestBuilder(settings.UrlInfo); SnowflakeDataMapper.SetJsonMapperOptions(settings.JsonMapperOptions); }
public void UrlInfo_Ctor() { var urlInfo = new UrlInfo("account-url.snowflakecomputing.com"); var settings = new SnowflakeClientSettings(new AuthInfo("user", "pw", "account"), null, urlInfo); Assert.AreEqual("account-url.snowflakecomputing.com", settings.UrlInfo.Host); Assert.AreEqual("https", settings.UrlInfo.Protocol); Assert.AreEqual(443, settings.UrlInfo.Port); }
public void UrlInfo_Uri(string url, string expectedProtocol, int expectedPort) { var authInfo = new AuthInfo("user", "pw", "account"); var urlInfo = new UrlInfo(new Uri(url)); var settings = new SnowflakeClientSettings(authInfo, null, urlInfo); Assert.AreEqual(url.Replace(expectedProtocol + "://", ""), settings.UrlInfo.Host); Assert.AreEqual(expectedPort, settings.UrlInfo.Port); Assert.AreEqual(expectedProtocol, settings.UrlInfo.Protocol); }
public void AuthInfo_Ctor(string user, string password, string account) { var authInfo = new AuthInfo(user, password, account); var settings = new SnowflakeClientSettings(authInfo); Assert.AreEqual($"{account}.snowflakecomputing.com", settings.UrlInfo.Host); Assert.AreEqual("https", settings.UrlInfo.Protocol); Assert.AreEqual(443, settings.UrlInfo.Port); Assert.AreEqual(user, settings.AuthInfo.User); Assert.AreEqual(password, settings.AuthInfo.Password); Assert.AreEqual(account, settings.AuthInfo.Account); }
private void ValidateClientSettings(SnowflakeClientSettings settings) { if (settings == null) { throw new ArgumentException("Settings object cannot be null."); } if (string.IsNullOrEmpty(settings.AuthInfo?.User)) { throw new ArgumentException("User name is either empty or null."); } if (string.IsNullOrEmpty(settings.AuthInfo?.Password)) { throw new ArgumentException("User password is either empty or null."); } if (string.IsNullOrEmpty(settings.AuthInfo?.Account)) { throw new ArgumentException("Snowflake account is either empty or null."); } if (settings.UrlInfo?.Protocol != "https" && settings.UrlInfo?.Protocol != "http") { throw new ArgumentException("URL Protocol should be either http or https."); } if (string.IsNullOrEmpty(settings.UrlInfo?.Host)) { throw new ArgumentException("URL Host cannot be empty."); } if (!settings.UrlInfo.Host.ToLower().EndsWith(".snowflakecomputing.com")) { throw new ArgumentException("URL Host should end up with '.snowflakecomputing.com'."); } }