Add AxesModelBackend to test setup

This commit is contained in:
Aleksi Häkli 2018-04-11 20:55:29 +03:00
parent d1f1f400b4
commit 146c3b2b39
2 changed files with 9 additions and 1 deletions

View file

@ -19,6 +19,11 @@ MIDDLEWARE = (
'django.contrib.auth.middleware.AuthenticationMiddleware',
)
AUTHENTICATION_BACKENDS = (
'axes.backends.AxesModelBackend',
'django.contrib.auth.backends.ModelBackend',
)
ROOT_URLCONF = 'axes.test_urls'
INSTALLED_APPS = (

View file

@ -5,6 +5,7 @@ import random
import string
import time
from django.http import HttpRequest
from django.test import TestCase, override_settings
from django.urls import reverse
from django.contrib.auth import authenticate
@ -386,6 +387,8 @@ class AccessAttemptTest(TestCase):
``log_user_login_failed`` should shortcircuit if an attempt to authenticate
with a custom authentication backend fails.
'''
authenticate(foo='bar')
request = HttpRequest()
request.user = self.user
authenticate(request=request, foo='bar')
self.assertEqual(AccessLog.objects.all().count(), 0)