Skip to content

Commit

Permalink
[s3] raise ImproperlyConfigured if no bucket name is set (#1313)
Browse files Browse the repository at this point in the history
  • Loading branch information
jschneier committed Sep 29, 2023
1 parent d8a097d commit 9eeb8c3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
2 changes: 2 additions & 0 deletions storages/backends/s3.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,8 @@ def __init__(self, **settings):
super().__init__(**settings)

check_location(self)
if not self.bucket_name:
raise ImproperlyConfigured("Setting a bucket name is required.")

if (self.access_key or self.secret_key) and self.session_profile:
raise ImproperlyConfigured(
Expand Down
5 changes: 5 additions & 0 deletions tests/test_s3.py
Original file line number Diff line number Diff line change
Expand Up @@ -956,6 +956,11 @@ def test_auth_config(self):
access_key="foo", secret_key="boo", session_profile="moo"
)

def test_bucket_name_required(self):
with override_settings(AWS_STORAGE_BUCKET_NAME=None):
with self.assertRaises(ImproperlyConfigured):
s3.S3Storage()


class S3StaticStorageTests(TestCase):
def setUp(self):
Expand Down

0 comments on commit 9eeb8c3

Please sign in to comment.