Skip to content
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
Empty file added tests/integration/__init__.py
Empty file.
37 changes: 28 additions & 9 deletions tests/integration/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,25 @@
CLIENT_KEY_ENV = "CLIENT_SECRET"


class Secret:
"""
Class to hold sensitive data in testing. This prevents passwords
and such to be printed in logs or any other reports.
More info: https://github.com/pytest-dev/pytest/issues/8613
NOTE: be careful, assert Secret("") == "" would still print
on failure
"""

def __init__(self, value):
self.value = value

def __repr__(self):
return "Secret(********)"

def __str___(self):
return "*******"


def must_env(var_name: str) -> str:
assert var_name in environ, f"Expected {var_name} to be provided in environment"
LOGGER.info(f"{var_name}: {environ[var_name]}")
Expand All @@ -39,8 +58,8 @@ def client_id() -> str:


@fixture(scope="session")
def client_key() -> str:
return urllib.parse.quote_plus(must_env(CLIENT_KEY_ENV))
def client_key() -> Secret:
return Secret(urllib.parse.quote_plus(must_env(CLIENT_KEY_ENV)))


@fixture(scope="session")
Expand All @@ -51,27 +70,27 @@ def account_name() -> str:
@fixture(scope="session")
def engine(
client_id: str,
client_key: str,
client_key: Secret,
database_name: str,
engine_name: str,
account_name: str,
) -> Engine:
return create_engine(
f"firebolt://{client_id}:{client_key}@{database_name}/{engine_name}"
f"firebolt://{client_id}:{client_key.value}@{database_name}/{engine_name}"
+ f"?account_name={account_name}"
)


@fixture(scope="session")
def engine_service_account(
client_id: str,
client_key: str,
client_key: Secret,
database_name: str,
engine_name: str,
account_name: str,
) -> Engine:
return create_engine(
f"firebolt://{client_id}:{client_key}@{database_name}/{engine_name}"
f"firebolt://{client_id}:{client_key.value}@{database_name}/{engine_name}"
+ f"?account_name={account_name}"
)

Expand All @@ -91,14 +110,14 @@ def connection_service_account(engine_service_account: Engine) -> Connection:
@fixture()
def async_engine(
client_id: str,
client_key: str,
client_key: Secret,
database_name: str,
engine_name: str,
account_name: str,
) -> Engine:
return create_async_engine(
f"asyncio+firebolt://{client_id}:{client_key}@{database_name}/{engine_name}"
+ f"?account_name={account_name}"
f"asyncio+firebolt://{client_id}:{client_key.value}@{database_name}/"
+ f"{engine_name}?account_name={account_name}"
)


Expand Down
6 changes: 4 additions & 2 deletions tests/integration/test_sqlalchemy_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
from sqlalchemy.engine.base import Connection, Engine
from sqlalchemy.types import ARRAY, INTEGER, TypeEngine

from .conftest import Secret # noqa: I252 relative import


@pytest.mark.usefixtures("setup_test_tables")
class TestFireboltDialect:
Expand All @@ -25,13 +27,13 @@ def test_create_ex_table(
def test_set_params(
self,
client_id: str,
client_key: str,
client_key: Secret,
database_name: str,
engine_name: str,
account_name: str,
):
engine = create_engine(
f"firebolt://{client_id}:{client_key}@{database_name}/{engine_name}"
f"firebolt://{client_id}:{client_key.value}@{database_name}/{engine_name}"
+ f"?account_name={account_name}"
)
with engine.connect() as connection:
Expand Down