Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[s3] raise ImproperlyConfigured if no bucket name is set #1313

Merged
merged 1 commit into from
Sep 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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