Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stop using invalid password authenticator #61

Merged
merged 6 commits into from
Jun 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Fixed
- Stop using invalid `password` authenticator.

## [1.0.0]
### Added
- Add support for external browser authentication in `SnowflakeDeserializer`.
Expand Down
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["password", "externalbrowser"]] = "password"
authenticator: Optional[str] = DEFAULT_AUTHENTICATOR

def __post_init__(self):
"""Validate input for optional attributes."""
if self.authenticator == "password" 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 the "
"authenticator is `password`. 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, using `password` authenticator."""
"""Test `DatabaseConfiguration` - no password nor authenticator=externalbrowser."""
with pytest.raises(ValueError):
_ = DatabaseConfiguration(
database="some_db",
Expand Down
Loading