From dc170e38870d90a2ccdbb98c72c503101af14380 Mon Sep 17 00:00:00 2001 From: David Hotham Date: Sat, 16 Oct 2021 18:47:38 +0100 Subject: [PATCH] [azure] Fix regression with interpretation of ``AZURE_CUSTOM_DOMAIN`` (#1076) Closes #1073 --- CHANGELOG.rst | 5 +++++ storages/backends/azure_storage.py | 7 ++++--- tests/test_azure.py | 4 ++-- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 8e17586aa..d8389449f 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,6 +1,11 @@ django-storages CHANGELOG ========================= +Azure +----- + +- ``AZURE_CUSTOM_DOMAIN`` now once again behaves as it did at 1.11: that is, it is a full domain, rather than only a replacement for the ``blob.core.windows.net`` part of the domain. + 1.12.1 (2021-10-11) ******************* diff --git a/storages/backends/azure_storage.py b/storages/backends/azure_storage.py index 64f0978e4..23509a569 100644 --- a/storages/backends/azure_storage.py +++ b/storages/backends/azure_storage.py @@ -151,10 +151,11 @@ def _get_service_client(self): if self.connection_string is not None: return BlobServiceClient.from_connection_string(self.connection_string) - account_domain = self.custom_domain or "blob.core.windows.net" - account_url = "{}://{}.{}".format( - self.azure_protocol, self.account_name, account_domain + account_domain = self.custom_domain or "{}.blob.core.windows.net".format( + self.account_name ) + account_url = "{}://{}".format(self.azure_protocol, account_domain) + credential = None if self.account_key: credential = self.account_key diff --git a/tests/test_azure.py b/tests/test_azure.py index b80e9c05d..fa276848b 100644 --- a/tests/test_azure.py +++ b/tests/test_azure.py @@ -231,7 +231,7 @@ def test_container_client_params_account_key(self): bsc_mocked.return_value.get_container_client.return_value = client_mock self.assertEqual(storage.client, client_mock) bsc_mocked.assert_called_once_with( - 'https://foo_name.foo_domain', + 'https://foo_domain', credential='foo_key') def test_container_client_params_sas_token(self): @@ -247,7 +247,7 @@ def test_container_client_params_sas_token(self): bsc_mocked.return_value.get_container_client.return_value = client_mock self.assertEqual(storage.client, client_mock) bsc_mocked.assert_called_once_with( - 'http://foo_name.foo_domain', + 'http://foo_domain', credential='foo_token') def test_container_client_params_token_credential(self):