Ticket #13190: 13190_empty_auth_backends.diff
File 13190_empty_auth_backends.diff, 2.6 KB (added by , 14 years ago) |
---|
-
django/contrib/auth/__init__.py
39 39 backends = [] 40 40 for backend_path in settings.AUTHENTICATION_BACKENDS: 41 41 backends.append(load_backend(backend_path)) 42 if len(backends) == 0: 43 raise ImproperlyConfigured, 'settings.AUTHENTICATION_BACKENDS is empty.' 42 44 return backends 43 45 44 46 def authenticate(**credentials): -
django/contrib/auth/tests/__init__.py
1 from django.contrib.auth.tests.auth_backends import BackendTest, RowlevelBackendTest, AnonymousUserBackendTest, NoAnonymousUserBackendTest 1 from django.contrib.auth.tests.auth_backends import BackendTest, RowlevelBackendTest, AnonymousUserBackendTest, NoAnonymousUserBackendTest, NoBackendTest 2 2 from django.contrib.auth.tests.basic import BASIC_TESTS 3 3 from django.contrib.auth.tests.decorators import LoginRequiredTestCase 4 4 from django.contrib.auth.tests.forms import UserCreationFormTest, AuthenticationFormTest, SetPasswordFormTest, PasswordChangeFormTest, UserChangeFormTest, PasswordResetFormTest -
django/contrib/auth/tests/auth_backends.py
1 1 from django.conf import settings 2 2 from django.contrib.auth.models import User, Group, Permission, AnonymousUser 3 3 from django.contrib.contenttypes.models import ContentType 4 from django.core.exceptions import ImproperlyConfigured 4 5 from django.test import TestCase 5 6 6 7 … … 245 246 246 247 def test_get_all_permissions(self): 247 248 self.assertEqual(self.user1.get_all_permissions(TestObj()), set()) 249 250 class NoBackendTest(TestCase): 251 """ 252 Tests that an appropriate error is raised if no auth backends are provided. 253 """ 254 backend = () 255 256 def setUp(self): 257 self.curr_auth = settings.AUTHENTICATION_BACKENDS 258 settings.AUTHENTICATION_BACKENDS = self.backend 259 self.user = User.objects.create_user('test', 'test@example.com', 'test') 260 261 def tearDown(self): 262 settings.AUTHENTICATION_BACKENDS = self.curr_auth 263 264 def test_raises_exception(self): 265 self.assertRaises(ImproperlyConfigured, self.user.has_perm, ('perm', TestObj(),))