Skip to content

Commit

Permalink
fix issues
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-knozderko committed May 8, 2024
1 parent 6468c82 commit 459ead6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
7 changes: 0 additions & 7 deletions Snowflake.Data/Core/Session/ConnectionPoolManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -140,13 +140,6 @@ public SessionPool GetPool(string connectionString, SecureString password)
public SessionPool GetPool(string connectionString)
{
s_logger.Debug($"ConnectionPoolManager::GetPool");
// unless it is an external browser then those two must be passed along
var connStr = $";{connectionString.ToLower()};";
if (!connStr.Contains(";password=") && connStr.Contains(";user="))
{
s_logger.Error($"To obtain a pool a password must to be given with a connection string or SecureString parameter");
throw new SnowflakeDbException(SFError.MISSING_CONNECTION_PROPERTY, "Could not provide the pool without the password");
}
return GetPool(connectionString, null);
}

Expand Down
11 changes: 11 additions & 0 deletions Snowflake.Data/Core/Session/SessionPool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ private static Tuple<ConnectionPoolConfig, string> ExtractConfig(string connecti
{
var properties = SFSessionProperties.ParseConnectionString(connectionString, password);
var extractedProperties = SFSessionHttpClientProperties.ExtractAndValidate(properties);
ValidatePasswordProvided(properties);
return Tuple.Create(extractedProperties.BuildConnectionPoolConfig(), properties.ConnectionStringWithoutSecrets);
}
catch (Exception exception)
Expand All @@ -118,6 +119,16 @@ private static Tuple<ConnectionPoolConfig, string> ExtractConfig(string connecti
}
}

private static void ValidatePasswordProvided(SFSessionProperties properties)
{
var isPasswordGiven = !string.IsNullOrEmpty(properties[SFSessionProperty.PASSWORD]);
if (!isPasswordGiven)
{
s_logger.Error($"To obtain a pool a password must to be given with a connection string or SecureString parameter");
throw new SnowflakeDbException(SFError.MISSING_CONNECTION_PROPERTY, "Could not provide the pool without the password");
}
}

internal SFSession GetSession(string connStr, SecureString password)
{
s_logger.Debug("SessionPool::GetSession" + PoolIdentification());
Expand Down

0 comments on commit 459ead6

Please sign in to comment.