Skip to content

Commit

Permalink
[deps] Added support for Django 4.1 and Django 4.2
Browse files Browse the repository at this point in the history
- Dropped support for Django 4.0
- Dropped support for Python 3.7
- Bumped weasyprint~=59.0
- Bumped dj-rest-auth~=4.0.1

**Important**: dj-rest-auth>3 changed configuration settings.
It is recommended to review your Django project settings while
upgrading.
  • Loading branch information
pandafy committed Jun 26, 2023
1 parent 112ee8a commit 265f88a
Show file tree
Hide file tree
Showing 14 changed files with 36 additions and 36 deletions.
7 changes: 3 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,8 @@ jobs:
- "3.10"
django-version:
- django~=3.2.0
- django~=4.0.0
include:
- django-version: django~=3.2.0
python-version: 3.7
- django~=4.1.0
- django~=4.2.0

steps:
- uses: actions/checkout@v2
Expand Down Expand Up @@ -54,6 +52,7 @@ jobs:
- name: Install openwisp-radius
run: |
pip install -e .[saml,openvpn_status]
pip install "openwisp-utils[rest,celery] @ https://github.com/openwisp/openwisp-utils/tarball/master"
pip install ${{ matrix.django-version }}
- name: QA checks
Expand Down
3 changes: 0 additions & 3 deletions openwisp_radius/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,3 @@ def get_version():
rev = 0
version = '%s%s%s' % (version, VERSION[3][0:1], rev)
return version


default_app_config = 'openwisp_radius.apps.OpenwispRadiusConfig'
2 changes: 1 addition & 1 deletion openwisp_radius/api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ def _disable_radius_token_auth(self, user):

def is_valid(self, raise_exception=False):
try:
return super().is_valid(raise_exception)
return super().is_valid(raise_exception=raise_exception)
except serializers.ValidationError as error:
request = self.context.get('request', None)
if request:
Expand Down
4 changes: 2 additions & 2 deletions openwisp_radius/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ class ObtainAuthTokenView(
UserDetailsUpdaterMixin,
):
throttle_scope = 'obtain_auth_token'
serializer_class = rest_auth_settings.TokenSerializer
serializer_class = rest_auth_settings.api_settings.TOKEN_SERIALIZER
auth_serializer_class = AuthTokenSerializer
authentication_classes = [SesameAuthentication]

Expand Down Expand Up @@ -383,7 +383,7 @@ def post(self, request, *args, **kwargs):
)
response = RadiusUserSerializer(user).data
context = {'view': self, 'request': request}
token_data = rest_auth_settings.TokenSerializer(
token_data = rest_auth_settings.api_settings.TOKEN_SERIALIZER(
token, context=context
).data
token_data['auth_token'] = token_data.pop('key')
Expand Down
5 changes: 5 additions & 0 deletions openwisp_radius/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,3 +203,8 @@ def regiser_menu_groups(self):
position=70,
config={'label': _('RADIUS'), 'items': items, 'icon': 'ow-radius'},
)


del ApiAppConfig
del AccountConfig
del SocialAccountConfig
9 changes: 6 additions & 3 deletions openwisp_radius/tests/test_api/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
import swapper
from allauth.account.forms import default_token_generator
from allauth.account.utils import user_pk_to_url_str
from dj_rest_auth.tests.utils import (
override_api_settings as override_dj_rest_auth_settings,
)
from django.conf import settings
from django.contrib.auth import get_user_model
from django.contrib.auth.models import Permission
Expand Down Expand Up @@ -477,7 +480,7 @@ def test_email_verification_sent(self):

if (sys.version_info.major, sys.version_info.minor) > (3, 6):

@override_settings(REST_USE_JWT=True)
@override_dj_rest_auth_settings(USE_JWT=True)
def test_registration_with_jwt(self):
user_count = User.objects.all().count()
url = reverse('radius:rest_register', args=[self.default_org.slug])
Expand All @@ -491,8 +494,8 @@ def test_registration_with_jwt(self):
},
)
self.assertEqual(r.status_code, 201)
self.assertIn('access_token', r.data)
self.assertIn('refresh_token', r.data)
self.assertIn('access', r.data)
self.assertIn('refresh', r.data)
self.assertEqual(User.objects.all().count(), user_count + 1)

def test_api_batch_add_users(self):
Expand Down
7 changes: 1 addition & 6 deletions openwisp_radius/tests/test_token.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import sys
from datetime import datetime, timedelta
from unittest import mock

Expand Down Expand Up @@ -220,11 +219,7 @@ def test_org_sms_message(self, sms_message_mock, *args):
)
radius_settings.save()
token = self._create_token()
if sys.version_info < (3, 8):
# TODO: Remove when dropping support for Python 3.7
sms_body = sms_message_mock.call_args[1]['body']
else:
sms_body = sms_message_mock.call_args.kwargs['body']
sms_body = sms_message_mock.call_args.kwargs['body']
self.assertEqual(
sms_body,
radius_settings.sms_message.format(
Expand Down
2 changes: 0 additions & 2 deletions requirements-test.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
responses
djangorestframework-simplejwt
django-cors-headers>=2.5.2
redis~=3.5.0
packaging
sphinx~=4.2.0
openwisp-sphinx-theme~=1.0.0
freezegun
django-extensions
Expand Down
15 changes: 8 additions & 7 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,22 +35,23 @@
include_package_data=True,
zip_safe=False,
install_requires=[
'django>=3.0,<=4.1.0',
(
'openwisp-users '
'@ https://github.com/openwisp/openwisp-users/tarball/'
'master'
),
'openwisp-utils[rest,celery] @ '
'https://github.com/openwisp/openwisp-utils/tarball/master',
(
'openwisp-utils[rest,celery] @ '
'https://github.com/openwisp/openwisp-utils/tarball/master'
),
'passlib~=1.7.1',
'djangorestframework-link-header-pagination~=0.1.1',
'weasyprint>=43,<53',
'dj-rest-auth~=2.1.6',
'weasyprint~=59.0',
'dj-rest-auth~=4.0.1',
'django-sendsms~=0.5.0',
'jsonfield~=3.1.0',
'django-private-storage~=3.0',
'django-ipware~=3.0.0',
'django-private-storage~=3.1.0',
'django-ipware~=5.0.0',
'pyrad~=2.4',
],
extras_require={
Expand Down
1 change: 0 additions & 1 deletion tests/openwisp2/sample_radius/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
default_app_config = 'openwisp2.sample_radius.apps.SampleOpenwispRadiusConfig'
3 changes: 3 additions & 0 deletions tests/openwisp2/sample_radius/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,6 @@ def connect_signals(self):
dispatch_uid='send_email_on_new_accounting',
)
return super().connect_signals()


del OpenwispRadiusConfig
1 change: 0 additions & 1 deletion tests/openwisp2/sample_users/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
default_app_config = 'openwisp2.sample_users.apps.SampleUsersConfig'
3 changes: 3 additions & 0 deletions tests/openwisp2/sample_users/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@
class SampleUsersConfig(OpenwispUsersConfig):
name = 'openwisp2.sample_users'
label = 'sample_users'


del OpenwispUsersConfig
10 changes: 4 additions & 6 deletions tests/openwisp2/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,12 +268,10 @@
SENDSMS_BACKEND = 'sendsms.backends.console.SmsBackend'
OPENWISP_RADIUS_EXTRA_NAS_TYPES = (('cisco', 'Cisco Router'),)

REST_AUTH_SERIALIZERS = {
'PASSWORD_RESET_SERIALIZER': 'openwisp_radius.api.serializers.PasswordResetSerializer'
}

REST_AUTH_REGISTER_SERIALIZERS = {
'REGISTER_SERIALIZER': 'openwisp_radius.api.serializers.RegisterSerializer'
REST_AUTH = {
'SESSION_LOGIN': False,
'PASSWORD_RESET_SERIALIZER': 'openwisp_radius.api.serializers.PasswordResetSerializer',
'REGISTER_SERIALIZER': 'openwisp_radius.api.serializers.RegisterSerializer',
}

ACCOUNT_EMAIL_CONFIRMATION_ANONYMOUS_REDIRECT_URL = 'email_confirmation_success'
Expand Down

0 comments on commit 265f88a

Please sign in to comment.