diff --git a/gooddata-sdk/gooddata_sdk/catalog/data_source/declarative_model/data_source.py b/gooddata-sdk/gooddata_sdk/catalog/data_source/declarative_model/data_source.py index da5272f73..b28657e70 100644 --- a/gooddata-sdk/gooddata_sdk/catalog/data_source/declarative_model/data_source.py +++ b/gooddata-sdk/gooddata_sdk/catalog/data_source/declarative_model/data_source.py @@ -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])) diff --git a/gooddata-sdk/gooddata_sdk/catalog/data_source/service.py b/gooddata-sdk/gooddata_sdk/catalog/data_source/service.py index 1aa977d23..e3e0b88fb 100644 --- a/gooddata-sdk/gooddata_sdk/catalog/data_source/service.py +++ b/gooddata-sdk/gooddata_sdk/catalog/data_source/service.py @@ -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) ) diff --git a/gooddata-sdk/tests/catalog/test_catalog_data_source.py b/gooddata-sdk/tests/catalog/test_catalog_data_source.py index f69c4e7d1..3da0d8904 100644 --- a/gooddata-sdk/tests/catalog/test_catalog_data_source.py +++ b/gooddata-sdk/tests/catalog/test_catalog_data_source.py @@ -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 @@ -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( @@ -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( @@ -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( @@ -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(