Permalink
Browse files

Merge pull request #65 from percipient/drop-1.10

Remove obsolete code, support Django 2.0/2.1
  • Loading branch information...
clokep committed Sep 18, 2018
2 parents 6d666d6 + 51a8129 commit 57780459094e1a5a484f74f74829ffbe3b4edb9c
Showing with 22 additions and 43 deletions.
  1. +6 −0 CHANGELOG.rst
  2. +1 −4 allauth_2fa/adapter.py
  3. +2 −8 allauth_2fa/middleware.py
  4. +1 −4 allauth_2fa/views.py
  5. +2 −7 tests/settings.py
  6. +4 −18 tests/test_allauth_2fa.py
  7. +6 −2 tox.ini
View
@@ -3,6 +3,12 @@
Changelog
#########
next
====
* Remove more code that was for Django < 1.11.
* Officially support Django 2.0 and Django 2.1.
0.6 February 13, 2018
=====================
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."""
View
@@ -8,9 +8,11 @@ envlist =
# django-otp 0.3.12 and Django 1.11 are the earliest supported version.
py{27,34,35,36}-django111-dotp{03,04,master}
# Django 2.0 drops support for Python 2.7.
py{34,35,36}-django20-dotp{03,04,master}
py{34,35,36}-django20-dotp{03,04}
# django-otp 0.5 adds support for Django 2.1
py{35,36}-django21-dotp{05,master}
# Django master drops support for Python 3.4.
py{35,36}-djangomaster-dotp{03,04,master}
py{35,36}-djangomaster-dotp{03,04,05,master}
# Check code style.
flake8
skip_missing_interpreters = True
@@ -25,9 +27,11 @@ deps =
coverage
django111: Django>=1.11,<2.0
django20: Django>=2.0,<2.1
django21: Django>=2.1,<2.2
djangomaster: https://codeload.github.com/django/django/zip/master
dotp03: django-otp>=0.3,<0.4
dotp04: django-otp>=0.4,<0.5
dotp05: django-otp>=0.5,<0.6
dotpmaster: hg+https://bitbucket.org/psagers/django-otp#egg=subdir&subdirectory=django-otp
[testenv:flake8]

0 comments on commit 5778045

Please sign in to comment.