1
0
mirror of https://github.com/django/django.git synced 2025-10-24 14:16:09 +00:00

Fixed #34542 -- Made createsuperuser handle required blank fields in non-interactive mode.

This commit is contained in:
Mateusz Więckowski
2023-07-31 18:10:32 +02:00
committed by Mariusz Felisiak
parent 0f3b1a783d
commit 5aa4c0b675
2 changed files with 35 additions and 1 deletions

View File

@@ -968,6 +968,36 @@ class CreatesuperuserManagementCommandTestCase(TestCase):
stderr=new_io,
)
def test_blank_email_allowed_non_interactive(self):
new_io = StringIO()
call_command(
"createsuperuser",
email="",
username="joe",
interactive=False,
stdout=new_io,
stderr=new_io,
)
self.assertEqual(new_io.getvalue().strip(), "Superuser created successfully.")
u = User.objects.get(username="joe")
self.assertEqual(u.email, "")
@mock.patch.dict(os.environ, {"DJANGO_SUPERUSER_EMAIL": ""})
def test_blank_email_allowed_non_interactive_environment_variable(self):
new_io = StringIO()
call_command(
"createsuperuser",
username="joe",
interactive=False,
stdout=new_io,
stderr=new_io,
)
self.assertEqual(new_io.getvalue().strip(), "Superuser created successfully.")
u = User.objects.get(username="joe")
self.assertEqual(u.email, "")
def test_password_validation_bypass(self):
"""
Password validation can be bypassed by entering 'y' at the prompt.