summaryrefslogtreecommitdiff
path: root/tests/auth_tests/test_forms.py
diff options
context:
space:
mode:
authorTim Graham <timograham@gmail.com>2016-06-21 09:06:34 -0400
committerTim Graham <timograham@gmail.com>2016-06-21 16:19:37 -0400
commit39805686b364358af725b695924a5a6dfa7f5302 (patch)
tree5b637ab2856e755b70e5147f55dc82a62237644c /tests/auth_tests/test_forms.py
parent5ce660cd65a4ffcf74d94ba987fe03a16b7436a0 (diff)
Refs #21379, #26719 -- Moved username normalization to AbstractBaseUser.
Thanks Huynh Thanh Tam for the initial patch and Claude Paroz for review.
Diffstat (limited to 'tests/auth_tests/test_forms.py')
-rw-r--r--tests/auth_tests/test_forms.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/auth_tests/test_forms.py b/tests/auth_tests/test_forms.py
index d2ce828eb8..fe22d1e20b 100644
--- a/tests/auth_tests/test_forms.py
+++ b/tests/auth_tests/test_forms.py
@@ -120,6 +120,22 @@ class UserCreationFormTest(TestDataMixin, TestCase):
self.assertFalse(form.is_valid())
@skipIf(six.PY2, "Python 2 doesn't support unicode usernames by default.")
+ def test_normalize_username(self):
+ # The normalization happens in AbstractBaseUser.clean() and ModelForm
+ # validation calls Model.clean().
+ ohm_username = 'testΩ' # U+2126 OHM SIGN
+ data = {
+ 'username': ohm_username,
+ 'password1': 'pwd2',
+ 'password2': 'pwd2',
+ }
+ form = UserCreationForm(data)
+ self.assertTrue(form.is_valid())
+ user = form.save()
+ self.assertNotEqual(user.username, ohm_username)
+ self.assertEqual(user.username, 'testΩ') # U+03A9 GREEK CAPITAL LETTER OMEGA
+
+ @skipIf(six.PY2, "Python 2 doesn't support unicode usernames by default.")
def test_duplicate_normalized_unicode(self):
"""
To prevent almost identical usernames, visually identical but differing