From 8071b9557de30f31fd26aceed9cc80f4a9fe2cf9 Mon Sep 17 00:00:00 2001 From: Marcin Rudolf Date: Fri, 24 May 2024 12:25:01 +0200 Subject: [PATCH] configures destination credentials --- .../load/filesystem/test_azure_credentials.py | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/tests/load/filesystem/test_azure_credentials.py b/tests/load/filesystem/test_azure_credentials.py index 46d3f5b9ed..4ee2ec46db 100644 --- a/tests/load/filesystem/test_azure_credentials.py +++ b/tests/load/filesystem/test_azure_credentials.py @@ -29,18 +29,20 @@ @pytest.fixture def az_service_principal_config() -> Optional[FilesystemConfiguration]: - """FS config with alternate azure credentials format if available in environment""" + """FS config with alternate azure credentials format if available in environment + + Working credentials of this type may be created as an app in Entra, which has + R/W/E access to the bucket (via ACL of particular container) + + """ credentials = AzureServicePrincipalCredentialsWithoutDefaults( azure_tenant_id=dlt.config.get("tests.az_sp_tenant_id", str), azure_client_id=dlt.config.get("tests.az_sp_client_id", str), azure_client_secret=dlt.config.get("tests.az_sp_client_secret", str), # type: ignore[arg-type] azure_storage_account_name=dlt.config.get("tests.az_sp_storage_account_name", str), ) - try: - credentials = resolve_configuration(credentials) - except ConfigFieldMissingException: - pytest.skip("Azure service principal credentials not available in environment") - return None + # + credentials = resolve_configuration(credentials, sections=("destination", "fsazureprincipal")) cfg = FilesystemConfiguration(bucket_url=AZ_BUCKET, credentials=credentials) return resolve_configuration(cfg) @@ -192,7 +194,8 @@ def test_azure_service_principal_fs_operations( fn = uuid4().hex # Try some file ops to see if the credentials work - fs.touch(f"{bucket}/{fn}") - files = fs.ls(bucket) - assert f"{bucket}/{fn}" in files - fs.delete(f"{bucket}/{fn}") + fs.touch(f"{bucket}/{fn}/{fn}") + files = fs.ls(f"{bucket}/{fn}") + assert f"{bucket}/{fn}/{fn}" in files + fs.delete(f"{bucket}/{fn}/{fn}") + fs.rmdir(f"{bucket}/{fn}")