diff options
| author | Tom <tom@tomforb.es> | 2017-09-09 18:06:20 +0100 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2017-11-03 20:00:08 -0400 |
| commit | b81905bfd4a745a407d246e899a7c0db1c7555be (patch) | |
| tree | 1b946b7896ad5eae75dd7ef5a2ee98575aac1941 /tests/auth_tests | |
| parent | 872be5976d1009ee8b90944a2fb14b1515172825 (diff) | |
Fixed #28571 -- Added a prompt to bypass password validation in createsuperuser.
Diffstat (limited to 'tests/auth_tests')
| -rw-r--r-- | tests/auth_tests/test_management.py | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/auth_tests/test_management.py b/tests/auth_tests/test_management.py index 539ac84424..4e60333c9d 100644 --- a/tests/auth_tests/test_management.py +++ b/tests/auth_tests/test_management.py @@ -27,6 +27,7 @@ from .models import ( MOCK_INPUT_KEY_TO_PROMPTS = { # @mock_inputs dict key: [expected prompt messages], + 'bypass': ['Bypass password validation and create user anyway? [y/N]: '], 'email': ['Email address: '], 'username': ['Username: ', lambda: "Username (leave blank to use '%s'): " % get_default_username()], } @@ -531,6 +532,7 @@ class CreatesuperuserManagementCommandTestCase(TestCase): 'password': bad_then_good_password, 'username': 'joe1234567890', 'email': '', + 'bypass': 'n', }) def test(self): call_command( @@ -564,6 +566,34 @@ class CreatesuperuserManagementCommandTestCase(TestCase): test(self) + def test_password_validation_bypass(self): + """ + Password validation can be bypassed by entering 'y' at the prompt. + """ + new_io = StringIO() + + @mock_inputs({ + 'password': '1234567890', + 'username': 'joe1234567890', + 'email': '', + 'bypass': 'y', + }) + def test(self): + call_command( + 'createsuperuser', + interactive=True, + stdin=MockTTY(), + stdout=new_io, + stderr=new_io, + ) + self.assertEqual( + new_io.getvalue().strip(), + 'This password is entirely numeric.\n' + 'Superuser created successfully.' + ) + + test(self) + def test_invalid_username(self): """Creation fails if the username fails validation.""" user_field = User._meta.get_field(User.USERNAME_FIELD) |
