Skip to content

Commit

Permalink
[azure] Fix regression with interpretation of AZURE_CUSTOM_DOMAIN (
Browse files Browse the repository at this point in the history
…#1076)

Closes #1073
  • Loading branch information
dimbleby authored Oct 16, 2021
1 parent 34072c3 commit dc170e3
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -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)
*******************

Expand Down
7 changes: 4 additions & 3 deletions storages/backends/azure_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions tests/test_azure.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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):
Expand Down

0 comments on commit dc170e3

Please sign in to comment.