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

Marcos/test pr 36349 #37696

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Avoid breaking existing connections
  • Loading branch information
ptiurin committed Apr 2, 2024
commit 857fe69b677055c223f5c40156279a1309f51b35
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ def parse_config(config: json, logger: AirbyteLogger) -> Dict[str, Any]:

:return: dictionary of firebolt.db.Connection-compatible kwargs
"""
auth = _determine_auth(config["client_id"], config["client_secret"])
# We should use client_id/client_secret, this code supports username/password for legacy users
auth = _determine_auth(config.get("client_id", config.get("username")),
config.get("client_secret", config.get("password")))
connection_args = {
"database": config["database"],
"auth": auth,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,16 @@ def config(request):
}
return args

@fixture()
def legacy_config(request):
args = {
"database": "my_database",
# @ is important here to determine the auth type
"username": "my@username",
"password": "my_password",
"engine": "my_engine",
}
return args

@fixture()
def config_no_engine():
Expand Down Expand Up @@ -99,6 +109,11 @@ def test_parse_config(config, logger):
result = parse_config(config, logger)
assert result["engine_url"] == "override_engine.api.firebolt.io"

def test_parse_legacy_config(legacy_config, logger):
result = parse_config(legacy_config, logger)
assert result["database"] == "my_database"
assert result["auth"].username == "my@username"
assert result["auth"].password == "my_password"

@patch("source_firebolt.database.connect")
def test_connection(mock_connection, config, config_no_engine, logger):
Expand Down
Loading