Skip to content

Commit 7eb6d0a

Browse files
committed
fix: persist DS password after layout upload, fix local creds
The layout PUT API does not persist data source passwords. Add an entities PATCH call in upload_demo_layout.py after the layout PUT to explicitly set the password. Also make _patch_ds_credentials conftest fixture use ds_password from test config as fallback when DS_PASSWORD env var is not set, fixing credential test failures in local mode.
1 parent 9eefe67 commit 7eb6d0a

2 files changed

Lines changed: 21 additions & 8 deletions

File tree

packages/gooddata-sdk/tests/conftest.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -60,15 +60,15 @@ def test_config(request):
6060

6161
@pytest.fixture(scope="session", autouse=True)
6262
def _patch_ds_credentials(test_config):
63-
"""Override demo-test-ds password in memory when DS_PASSWORD env var is set.
63+
"""Override demo-test-ds password in memory.
6464
65-
The credentials file (data_sources_credentials.yaml) is read by
66-
_credentials_from_file() and used by put_declarative_data_sources and
67-
test_data_sources_connection. Instead of rewriting the file on disk,
68-
we wrap the static method to patch the returned dict in memory.
65+
The credentials file (data_sources_credentials.yaml) contains a placeholder
66+
value for demo-test-ds. This fixture patches _credentials_from_file() to
67+
replace it with the real password — from DS_PASSWORD env var (staging) or
68+
from the test config ds_password (local).
6969
"""
70-
env_ds_password = os.environ.get("DS_PASSWORD")
71-
if not env_ds_password:
70+
ds_password = os.environ.get("DS_PASSWORD") or test_config.get("ds_password")
71+
if not ds_password:
7272
yield
7373
return
7474

@@ -80,7 +80,7 @@ def _patch_ds_credentials(test_config):
8080
def _patched_credentials_from_file(credentials_path):
8181
credentials = original(credentials_path)
8282
if "demo-test-ds" in credentials:
83-
credentials["demo-test-ds"] = env_ds_password
83+
credentials["demo-test-ds"] = ds_password
8484
return credentials
8585

8686
CatalogDataSourceService._credentials_from_file = _patched_credentials_from_file

packages/tests-support/upload_demo_layout.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,19 @@ def update_layout():
207207
print("Uploading test DS with physical model for demo", flush=True)
208208
rest_op_default("put", f"api/{api_version}/layout/dataSources", data_sources)
209209

210+
# Layout PUT does not persist passwords — set them via entities PATCH
211+
print("Setting data source passwords via entities API...", flush=True)
212+
for ds in data_sources.get("dataSources", []):
213+
ds_id = ds["id"]
214+
ds_password = ds.get("password")
215+
if ds_password:
216+
rest_op_jsonapi(
217+
"patch",
218+
f"api/{api_version}/entities/dataSources/{ds_id}",
219+
{"data": {"id": ds_id, "type": "dataSource", "attributes": {"password": ds_password}}},
220+
)
221+
print(f" Set password for DS '{ds_id}'", flush=True)
222+
210223
# Verify data sources were uploaded with permissions
211224
print("Verifying data source permissions...", flush=True)
212225
result = rest_op_default("get", f"api/{api_version}/layout/dataSources", raise_ex=False)

0 commit comments

Comments
 (0)