diff options
| author | Joeri Bekker <joeri@maykinmedia.nl> | 2015-03-08 13:33:22 +0100 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2015-03-16 12:13:49 -0400 |
| commit | 0ed20d5cc4bf94646ffd4e4fcbd963b9916039cd (patch) | |
| tree | 06fb7acf69a68da3bc59c6be18cae29d0c9111db /tests/auth_tests | |
| parent | 820381d38bc02ea8b92837ce869e7332a7db9913 (diff) | |
Fixed #23926 -- Improved validation error for custom permissions that are too long.
Diffstat (limited to 'tests/auth_tests')
| -rw-r--r-- | tests/auth_tests/test_management.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/auth_tests/test_management.py b/tests/auth_tests/test_management.py index 0e2fe8d0e7..d3b2ff18c5 100644 --- a/tests/auth_tests/test_management.py +++ b/tests/auth_tests/test_management.py @@ -565,3 +565,21 @@ class PermissionTestCase(TestCase): six.assertRaisesRegex(self, exceptions.ValidationError, "The verbose_name of auth.permission is longer than 244 characters", create_permissions, auth_app_config, verbosity=0) + + def test_custom_permission_name_length(self): + auth_app_config = apps.get_app_config('auth') + + ContentType.objects.get_by_natural_key('auth', 'permission') + custom_perm_name = 'a' * 256 + models.Permission._meta.permissions = [ + ('my_custom_permission', custom_perm_name), + ] + try: + msg = ( + "The permission name %s of auth.permission is longer than " + "255 characters" % custom_perm_name + ) + with self.assertRaisesMessage(exceptions.ValidationError, msg): + create_permissions(auth_app_config, verbosity=0) + finally: + models.Permission._meta.permissions = [] |
