Skip to content

Commit

Permalink
Use default authenticator from snowflake connector instead of None
Browse files Browse the repository at this point in the history
  • Loading branch information
dlouseiro committed Jun 11, 2024
1 parent 6459601 commit 43bc4a8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
13 changes: 7 additions & 6 deletions src/diepvries/deserializers/snowflake_deserializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
from collections import defaultdict
from dataclasses import asdict, dataclass
from functools import cached_property
from typing import Dict, List, Literal, Optional, Type
from typing import Dict, List, Optional, Type

from snowflake.connector import DictCursor, connect
from snowflake.connector.network import DEFAULT_AUTHENTICATOR

from .. import TABLE_PREFIXES, FieldDataType, FixedPrefixLoggerAdapter, TableType
from ..driving_key_field import DrivingKeyField
Expand All @@ -32,15 +33,15 @@ class DatabaseConfiguration:
warehouse: str
account: str
password: Optional[str] = None
authenticator: Optional[Literal["externalbrowser"]] = None
authenticator: Optional[str] = DEFAULT_AUTHENTICATOR

def __post_init__(self):
"""Validate input for optional attributes."""
if self.authenticator is None and not self.password:
if self.authenticator == DEFAULT_AUTHENTICATOR and not self.password:
raise ValueError(
"Password was not provided. It is a mandatory attribute when an "
"authenticator is not specified. Empty passwords are only allowed "
"when `authenticator='externalbrowser'`."
f"Password was not provided. It is a mandatory attribute when the "
f"authenticator is not `{DEFAULT_AUTHENTICATOR}`. Empty passwords are "
f"only allowed when `authenticator='externalbrowser'`."
)


Expand Down
2 changes: 1 addition & 1 deletion test/deserializers/test_snowflake_deserializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ def test_deserialized_target_tables(


def test_database_configuration_with_password_invalid_input():
"""Test `DatabaseConfiguration` without password nor an `authenticator`."""
"""Test `DatabaseConfiguration` - no password nor authenticator=externalbrowser."""
with pytest.raises(ValueError):
_ = DatabaseConfiguration(
database="some_db",
Expand Down

0 comments on commit 43bc4a8

Please sign in to comment.