feat(snowflake): better error message on key pair authentication (#7734)

Co-authored-by: Harshal Sheth <hsheth2@gmail.com>
This commit is contained in:
Aseem Bansal 2023-04-05 06:16:07 +05:30 committed by GitHub
parent 8d99babf75
commit a11a7fa9d0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 0 deletions

View File

@ -179,6 +179,14 @@ class BaseSnowflakeConfig(BaseTimeWindowConfig):
f"unsupported authenticator type '{v}' was provided," f"unsupported authenticator type '{v}' was provided,"
f" use one of {list(VALID_AUTH_TYPES.keys())}" f" use one of {list(VALID_AUTH_TYPES.keys())}"
) )
if (
values.get("private_key") is not None
or values.get("private_key_path") is not None
) and v != "KEY_PAIR_AUTHENTICATOR":
raise ValueError(
f"Either `private_key` and `private_key_path` is set but `authentication_type` is {v}. "
f"Should be set to 'KEY_PAIR_AUTHENTICATOR' when using key pair authentication"
)
if v == "KEY_PAIR_AUTHENTICATOR": if v == "KEY_PAIR_AUTHENTICATOR":
# If we are using key pair auth, we need the private key path and password to be set # If we are using key pair auth, we need the private key path and password to be set
if ( if (

View File

@ -238,6 +238,16 @@ def test_snowflake_config_with_no_connect_args_returns_base_connect_args():
} }
def test_private_key_set_but_auth_not_changed():
with pytest.raises(ValidationError):
SnowflakeV2Config.parse_obj(
{
"account_id": "acctname",
"private_key_path": "/a/random/path",
}
)
def test_snowflake_config_with_connect_args_overrides_base_connect_args(): def test_snowflake_config_with_connect_args_overrides_base_connect_args():
config: SnowflakeV2Config = SnowflakeV2Config.parse_obj( config: SnowflakeV2Config = SnowflakeV2Config.parse_obj(
{ {