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
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ def _inject_base(self, credentials: dict[str, Any]) -> DeclarativeDataSources:
)
data_sources.append(data_source.to_api(client_secret=client_secret))
else:
token = TokenCredentialsFromFile.token_from_file(credentials[data_source.id])
token = TokenCredentialsFromFile.token_from_file(
file_path=credentials[data_source.id], base64_encode=False
)
data_sources.append(data_source.to_api(token=token))
else:
data_sources.append(data_source.to_api(password=credentials[data_source.id]))
Expand Down
4 changes: 3 additions & 1 deletion gooddata-sdk/gooddata_sdk/catalog/data_source/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,9 @@ def test_data_sources_connection(
declarative_data_source.to_test_request(client_secret=client_secret)
)
else:
token = TokenCredentialsFromFile.token_from_file(credentials[declarative_data_source.id])
token = TokenCredentialsFromFile.token_from_file(
file_path=credentials[declarative_data_source.id], base64_encode=False
)
response = self._actions_api.test_data_source_definition(
declarative_data_source.to_test_request(token=token)
)
Expand Down
34 changes: 17 additions & 17 deletions gooddata-sdk/tests/catalog/test_catalog_data_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from __future__ import annotations

from pathlib import Path
from typing import Optional
from typing import Optional, Union
from unittest import mock
from unittest.mock import MagicMock

Expand Down Expand Up @@ -416,13 +416,13 @@ def test_delete_declarative_data_sources(test_config):
credentials_path = _current_dir / "load" / "data_source_credentials" / "data_sources_credentials.yaml"
expected_json_path = _current_dir / "expected" / "declarative_data_sources.json"

def token_from_file_side_effect(arg):
if arg == "~/home/secrets.json":
def token_from_file_side_effect(file_path: Union[str, Path], base64_encode: bool):
if file_path == "~/home/secrets.json":
return test_config["bigquery_token"]
elif arg == "databricks-token":
elif file_path == "databricks-token":
return test_config["databricks_token"]
else:
raise ValueError(f"Unexpected argument: {arg}")
raise ValueError(f"Unexpected argument: {file_path}")

TokenCredentialsFromFile.token_from_file = MagicMock(side_effect=token_from_file_side_effect)
ClientSecretCredentialsFromFile.client_secret_from_file = MagicMock(
Expand Down Expand Up @@ -460,13 +460,13 @@ def test_load_and_put_declarative_data_sources(test_config):
try:
sdk.catalog_data_source.put_declarative_data_sources(CatalogDeclarativeDataSources(data_sources=[]))

def token_from_file_side_effect(arg):
if arg == "~/home/secrets.json":
def token_from_file_side_effect(file_path: Union[str, Path], base64_encode: bool = True):
if file_path == "~/home/secrets.json":
return test_config["bigquery_token"]
elif arg == "databricks-token":
elif file_path == "databricks-token":
return test_config["databricks_token"]
else:
raise ValueError(f"Unexpected argument: {arg}")
raise ValueError(f"Unexpected argument: {file_path}")

TokenCredentialsFromFile.token_from_file = MagicMock(side_effect=token_from_file_side_effect)
ClientSecretCredentialsFromFile.client_secret_from_file = MagicMock(
Expand Down Expand Up @@ -506,13 +506,13 @@ def test_put_declarative_data_sources_connection(test_config):
# Must filter out databricks data sources for this test as they do not have valid URLs
data_sources_e.data_sources = [item for item in data_sources_e.data_sources if "databricks" not in item.id]

def token_from_file_side_effect(arg):
if arg == "~/home/secrets.json":
def token_from_file_side_effect(file_path: Union[str, Path], base64_encode: bool):
if file_path == "~/home/secrets.json":
return test_config["bigquery_token"]
elif arg == "databricks-token":
elif file_path == "databricks-token":
return test_config["databricks_token"]
else:
raise ValueError(f"Unexpected argument: {arg}")
raise ValueError(f"Unexpected argument: {file_path}")

TokenCredentialsFromFile.token_from_file = MagicMock(side_effect=token_from_file_side_effect)
ClientSecretCredentialsFromFile.client_secret_from_file = MagicMock(
Expand Down Expand Up @@ -605,13 +605,13 @@ def test_cache_strategy(test_config: dict):
path = _current_dir / "expected" / "declarative_data_sources.json"
credentials_path = _current_dir / "load" / "data_source_credentials" / "data_sources_credentials.yaml"

def token_from_file_side_effect(arg):
if arg == "~/home/secrets.json":
def token_from_file_side_effect(file_path: Union[str, Path], base64_encode: bool):
if file_path == "~/home/secrets.json":
return test_config["bigquery_token"]
elif arg == "databricks-token":
elif file_path == "databricks-token":
return test_config["databricks_token"]
else:
raise ValueError(f"Unexpected argument: {arg}")
raise ValueError(f"Unexpected argument: {file_path}")

TokenCredentialsFromFile.token_from_file = MagicMock(side_effect=token_from_file_side_effect)
ClientSecretCredentialsFromFile.client_secret_from_file = MagicMock(
Expand Down
Loading