Skip to content

Commit 6ef553d

Browse files
authored
[s3] Default url_protocol to https: if set to None (#1483)
1 parent 80031d3 commit 6ef553d

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

storages/backends/s3.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ def get_default_settings(self):
430430
"image/svg+xml",
431431
),
432432
),
433-
"url_protocol": setting("AWS_S3_URL_PROTOCOL", "https:"),
433+
"url_protocol": setting("AWS_S3_URL_PROTOCOL") or "https:",
434434
"endpoint_url": setting("AWS_S3_ENDPOINT_URL"),
435435
"proxies": setting("AWS_S3_PROXIES"),
436436
"region_name": setting("AWS_S3_REGION_NAME"),

tests/test_s3.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -719,6 +719,14 @@ def test_url_unsigned(self):
719719
self.storage.url("test_name")
720720
self.storage.unsigned_connection.meta.client.generate_presigned_url.assert_called_once()
721721

722+
def test_url_protocol(self):
723+
self.assertFalse(hasattr(settings, "AWS_S3_URL_PROTOCOL"))
724+
self.assertEqual(self.storage.url_protocol, "https:")
725+
726+
with override_settings(AWS_S3_URL_PROTOCOL=None):
727+
storage = s3.S3Storage()
728+
self.assertEqual(storage.url_protocol, "https:")
729+
722730
@mock.patch("storages.backends.s3.datetime")
723731
def test_storage_url_custom_domain_signed_urls(self, dt):
724732
key_id = "test-key"

0 commit comments

Comments
 (0)