|
@@ -4,7 +4,7 @@ from datetime import date
|
|
|
from django.conf import settings
|
|
|
from django.contrib.auth.models import User, Group, Permission, AnonymousUser
|
|
|
from django.contrib.auth.tests.utils import skipIfCustomUser
|
|
|
-from django.contrib.auth.tests.custom_user import ExtensionUser, CustomPermissionsUser
|
|
|
+from django.contrib.auth.tests.custom_user import ExtensionUser, CustomPermissionsUser, CustomUser
|
|
|
from django.contrib.contenttypes.models import ContentType
|
|
|
from django.core.exceptions import ImproperlyConfigured, PermissionDenied
|
|
|
from django.contrib.auth import authenticate
|
|
@@ -190,6 +190,24 @@ class CustomPermissionsUserModelBackendTest(BaseModelBackendTest, TestCase):
|
|
|
)
|
|
|
|
|
|
|
|
|
+@override_settings(AUTH_USER_MODEL='auth.CustomUser')
|
|
|
+class CustomUserModelBackendAuthenticateTest(TestCase):
|
|
|
+ """
|
|
|
+ Tests that the model backend can accept a credentials kwarg labeled with
|
|
|
+ custom user model's USERNAME_FIELD.
|
|
|
+ """
|
|
|
+
|
|
|
+ def test_authenticate(self):
|
|
|
+ test_user = CustomUser._default_manager.create_user(
|
|
|
+ email='test@example.com',
|
|
|
+ password='test',
|
|
|
+ date_of_birth=date(2006, 4, 25)
|
|
|
+ )
|
|
|
+ authenticated_user = authenticate(email='test@example.com', password='test')
|
|
|
+ self.assertEqual(test_user, authenticated_user)
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
class TestObj(object):
|
|
|
pass
|
|
|
|