Permalink
Browse files

Remove obsolete code.

  • Loading branch information...
clokep committed Sep 18, 2018
1 parent 7f7e6f9 commit b47b688c0d4535f384392ec08c3825eb5289f501
Showing with 10 additions and 41 deletions.
  1. +1 −4 allauth_2fa/adapter.py
  2. +2 −8 allauth_2fa/middleware.py
  3. +1 −4 allauth_2fa/views.py
  4. +2 −7 tests/settings.py
  5. +4 −18 tests/test_allauth_2fa.py
View
@@ -7,10 +7,7 @@
from allauth.exceptions import ImmediateHttpResponse
from django.http import HttpResponseRedirect
try:
from django.urls import reverse
except ImportError:
from django.core.urlresolvers import reverse
from django.urls import reverse
class OTPAdapter(DefaultAccountAdapter):
View
@@ -2,15 +2,9 @@
from django.conf import settings
from django.contrib import messages
try:
from django.urls import resolve, reverse
except ImportError:
from django.core.urlresolvers import resolve, reverse
try:
from django.utils.deprecation import MiddlewareMixin
except ImportError:
MiddlewareMixin = object
from django.shortcuts import redirect
from django.urls import resolve, reverse
from django.utils.deprecation import MiddlewareMixin
class AllauthTwoFactorMiddleware(MiddlewareMixin):
View
@@ -14,10 +14,7 @@
from django.contrib.sites.shortcuts import get_current_site
from django.http import Http404, HttpResponse, HttpResponseRedirect
from django.shortcuts import redirect
try:
from django.urls import reverse_lazy, reverse
except ImportError:
from django.core.urlresolvers import reverse_lazy, reverse
from django.urls import reverse, reverse_lazy
from django.views.generic import FormView, TemplateView, View
from django_otp.plugins.otp_static.models import StaticToken
View
@@ -59,7 +59,7 @@
'tests',
)
MW = (
MIDDLEWARE = (
# Configure Django auth package.
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
@@ -72,12 +72,7 @@
)
if django.VERSION < (2,):
MW += ('django.contrib.auth.middleware.SessionAuthenticationMiddleware',)
if django.VERSION > (1, 10):
MIDDLEWARE = MW
else:
MIDDLEWARE_CLASSES = MW
MIDDLEWARE += ('django.contrib.auth.middleware.SessionAuthenticationMiddleware',)
AUTHENTICATION_BACKENDS = (
'django.contrib.auth.backends.ModelBackend',
View
@@ -1,29 +1,15 @@
from allauth.account.signals import user_logged_in
import django
from django.conf import settings
from django.contrib.auth import get_user_model
from django.test import override_settings, TestCase
try:
from django.urls import reverse
except ImportError:
from django.core.urlresolvers import reverse
try:
from django.utils.deprecation import MiddlewareMixin
except ImportError:
MiddlewareMixin = None
from django.urls import reverse
from django_otp.oath import TOTP
from allauth_2fa.middleware import BaseRequire2FAMiddleware
if django.VERSION > (1, 10):
MIDDLEWARE_VAR = 'MIDDLEWARE'
else:
MIDDLEWARE_VAR = 'MIDDLEWARE_CLASSES'
class Test2Factor(TestCase):
def setUp(self):
# Track the signals sent via allauth.
@@ -303,7 +289,7 @@ def require_2fa(self, request):
# Don't redirect to an "allowed" URL.
LOGIN_REDIRECT_URL='/unnamed-view',
# Add the middleware that requires 2FA.
**{MIDDLEWARE_VAR: getattr(settings, MIDDLEWARE_VAR) + ('tests.test_allauth_2fa.Require2FA',)}
MIDDLEWARE=settings.MIDDLEWARE + ('tests.test_allauth_2fa.Require2FA',)
)
class TestRequire2FAMiddleware(TestCase):
def test_no_2fa(self):
@@ -348,10 +334,10 @@ def test_2fa(self):
INSTALLED_APPS=settings.INSTALLED_APPS + ('django.contrib.messages', ),
# This doesn't seem to stack nicely with the class-based one, so add the
# middleware here.
**{MIDDLEWARE_VAR: getattr(settings, MIDDLEWARE_VAR) + (
MIDDLEWARE=settings.MIDDLEWARE + (
'tests.test_allauth_2fa.Require2FA',
'django.contrib.messages.middleware.MessageMiddleware',
)}
),
)
def test_no_2fa_messages(self):
"""Test login behavior when 2FA is not configured and the messages framework is in use."""

0 comments on commit b47b688

Please sign in to comment.