#28016: Command createsuperuser does not validate username when using --username
-------------------------------------+-------------------------------------
Reporter: Ricardo S. A. Silva | Owner: Ricardo
| S. A. Silva
Type: Bug | Status: assigned
Component: Core (Management | Version: master
commands) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Ricardo S. A. Silva):
Done. PR updated.
{{{
--- a/tests/auth_tests/test_management.py
+++ b/tests/auth_tests/test_management.py
@@ -432,6 +432,38 @@ class
CreatesuperuserManagementCommandTestCase(TestCase):
stdout=new_io,
)
+ @mock_inputs({
+ 'password': 'nopasswd',
+ })
+ def test_invalid_username_by_command_line(self):
+ """
+ Creation should fail when an invalid username is inputted using
--username
+ """
+ with self.assertRaises(CommandError):
+ call_command(
+ "createsuperuser",
+ interactive=True,
+ username="%invalid%username",
+ stdin=MockTTY(),
+ )
+ self.assertEqual(CustomUser._default_manager.count(), 0)
+
+ @mock_inputs({
+ 'password': 'nopasswd',
+ })
+ def test_non_interactive_invalid_required_field(self):
+ """
+ Creation should fail when an invalid email is inputted using
--email
+ """
+ with self.assertRaises(CommandError):
+ call_command(
+ "createsuperuser",
+ interactive=True,
+ email="%invalid%email",
+ stdin=MockTTY(),
+ )
+ self.assertEqual(CustomUser._default_manager.count(), 0)
+
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/28016#comment:5>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/072.964bfeb4573d888b8d7827be448712e0%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.