Skip to content

Commit

Permalink
Bumps all-auth + fixes tests
Browse files Browse the repository at this point in the history
  • Loading branch information
iMerica committed Dec 20, 2021
1 parent c0c9d7e commit ea14056
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 61 deletions.
36 changes: 18 additions & 18 deletions demo/demo/urls.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from django.conf.urls import include, url
from django.urls import include, re_path
from django.contrib import admin
from django.views.generic import RedirectView, TemplateView
from drf_yasg.views import get_schema_view
Expand All @@ -12,43 +12,43 @@
)

urlpatterns = [
url(r'^$', TemplateView.as_view(template_name="home.html"), name='home'),
url(r'^signup/$', TemplateView.as_view(template_name="signup.html"),
re_path(r'^$', TemplateView.as_view(template_name="home.html"), name='home'),
re_path(r'^signup/$', TemplateView.as_view(template_name="signup.html"),
name='signup'),
url(r'^email-verification/$',
re_path(r'^email-verification/$',
TemplateView.as_view(template_name="email_verification.html"),
name='email-verification'),
url(r'^login/$', TemplateView.as_view(template_name="login.html"),
re_path(r'^login/$', TemplateView.as_view(template_name="login.html"),
name='login'),
url(r'^logout/$', TemplateView.as_view(template_name="logout.html"),
re_path(r'^logout/$', TemplateView.as_view(template_name="logout.html"),
name='logout'),
url(r'^password-reset/$',
re_path(r'^password-reset/$',
TemplateView.as_view(template_name="password_reset.html"),
name='password-reset'),
url(r'^password-reset/confirm/$',
re_path(r'^password-reset/confirm/$',
TemplateView.as_view(template_name="password_reset_confirm.html"),
name='password-reset-confirm'),

url(r'^user-details/$',
re_path(r'^user-details/$',
TemplateView.as_view(template_name="user_details.html"),
name='user-details'),
url(r'^password-change/$',
re_path(r'^password-change/$',
TemplateView.as_view(template_name="password_change.html"),
name='password-change'),
url(r'^resend-email-verification/$',
re_path(r'^resend-email-verification/$',
TemplateView.as_view(template_name="resend_email_verification.html"),
name='resend-email-verification'),


# this url is used to generate email content
url(r'^password-reset/confirm/(?P<uidb64>[0-9A-Za-z_\-]+)/(?P<token>[0-9A-Za-z]{1,13}-[0-9A-Za-z]{1,32})/$',
re_path(r'^password-reset/confirm/(?P<uidb64>[0-9A-Za-z_\-]+)/(?P<token>[0-9A-Za-z]{1,13}-[0-9A-Za-z]{1,32})/$',
TemplateView.as_view(template_name="password_reset_confirm.html"),
name='password_reset_confirm'),

url(r'^dj-rest-auth/', include('dj_rest_auth.urls')),
url(r'^dj-rest-auth/registration/', include('dj_rest_auth.registration.urls')),
url(r'^account/', include('allauth.urls')),
url(r'^admin/', admin.site.urls),
url(r'^accounts/profile/$', RedirectView.as_view(url='/', permanent=True), name='profile-redirect'),
url(r'^docs/$', schema_view.with_ui('swagger', cache_timeout=0), name='api_docs')
re_path(r'^dj-rest-auth/', include('dj_rest_auth.urls')),
re_path(r'^dj-rest-auth/registration/', include('dj_rest_auth.registration.urls')),
re_path(r'^account/', include('allauth.urls')),
re_path(r'^admin/', admin.site.urls),
re_path(r'^accounts/profile/$', RedirectView.as_view(url='/', permanent=True), name='profile-redirect'),
re_path(r'^docs/$', schema_view.with_ui('swagger', cache_timeout=0), name='api_docs')
]
2 changes: 1 addition & 1 deletion dj_rest_auth/__version__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
__title__ = 'dj-rest-auth'
__description__ = 'Authentication and Registration in Django Rest Framework.'
__url__ = 'http://github.com/iMerica/dj-rest-auth'
__version__ = '2.1.12'
__version__ = '2.2.0'
__author__ = '@iMerica https://github.com/iMerica'
__author_email__ = 'imichael@pm.me'
__license__ = 'MIT'
Expand Down
4 changes: 3 additions & 1 deletion dj_rest_auth/jwt_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,9 @@ def enforce_csrf(self, request):
"""
Enforce CSRF validation for session based authentication.
"""
check = CSRFCheck()
def dummy_get_response(request): # pragma: no cover
return None
check = CSRFCheck(dummy_get_response)
# populates request.META['CSRF_COOKIE'], which is used in process_view()
check.process_request(request)
reason = check.process_view(request, None, (), {})
Expand Down
30 changes: 15 additions & 15 deletions dj_rest_auth/tests/django_urls.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Moved in Django 1.8 from django to tests/auth_tests/urls.py

from django.conf.urls import url
from django.urls import re_path
from django.contrib.auth.decorators import login_required
from django.contrib.auth.urls import urlpatterns

Expand All @@ -23,29 +23,29 @@

# special urls for auth test cases
urlpatterns += [
url(r'^logout/custom_query/$', logout, dict(redirect_field_name='follow')),
url(r'^logout/next_page/$', logout, dict(next_page='/somewhere/')),
url(r'^logout/next_page/named/$', logout, dict(next_page='password_reset')),
url(r'^password_reset_from_email/$', password_reset, dict(from_email='staffmember@example.com')),
url(r'^password_reset/custom_redirect/$', password_reset, dict(post_reset_redirect='/custom/')),
url(r'^password_reset/custom_redirect/named/$', password_reset, dict(post_reset_redirect='password_reset')),
url(
re_path(r'^logout/custom_query/$', logout, dict(redirect_field_name='follow')),
re_path(r'^logout/next_page/$', logout, dict(next_page='/somewhere/')),
re_path(r'^logout/next_page/named/$', logout, dict(next_page='password_reset')),
re_path(r'^password_reset_from_email/$', password_reset, dict(from_email='staffmember@example.com')),
re_path(r'^password_reset/custom_redirect/$', password_reset, dict(post_reset_redirect='/custom/')),
re_path(r'^password_reset/custom_redirect/named/$', password_reset, dict(post_reset_redirect='password_reset')),
re_path(
r'^password_reset/html_email_template/$', password_reset,
dict(html_email_template_name='registration/html_password_reset_email.html'),
),
url(
re_path(
r'^reset/custom/(?P<uidb64>[0-9A-Za-z_\-]+)/(?P<token>[0-9A-Za-z]{1,13}-[0-9A-Za-z]{1,20})/$',
password_reset_confirm,
dict(post_reset_redirect='/custom/'),
),
url(
re_path(
r'^reset/custom/named/(?P<uidb64>[0-9A-Za-z_\-]+)/(?P<token>[0-9A-Za-z]{1,13}-[0-9A-Za-z]{1,20})/$',
password_reset_confirm,
dict(post_reset_redirect='password_reset'),
),
url(r'^password_change/custom/$', password_change, dict(post_change_redirect='/custom/')),
url(r'^password_change/custom/named/$', password_change, dict(post_change_redirect='password_reset')),
url(r'^admin_password_reset/$', password_reset, dict(is_admin_site=True)),
url(r'^login_required/$', login_required(password_reset)),
url(r'^login_required_login_url/$', login_required(password_reset, login_url='/somewhere/')),
re_path(r'^password_change/custom/$', password_change, dict(post_change_redirect='/custom/')),
re_path(r'^password_change/custom/named/$', password_change, dict(post_change_redirect='password_reset')),
re_path(r'^admin_password_reset/$', password_reset, dict(is_admin_site=True)),
re_path(r'^login_required/$', login_required(password_reset)),
re_path(r'^login_required_login_url/$', login_required(password_reset, login_url='/somewhere/')),
]
2 changes: 1 addition & 1 deletion dj_rest_auth/tests/requirements.pip
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
coveralls==1.11.1
django-allauth==0.42.0
django-allauth==0.47.0
djangorestframework-simplejwt==4.6.0
flake8==3.8.4
responses==0.12.1
Expand Down
7 changes: 0 additions & 7 deletions dj_rest_auth/tests/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,7 @@

TEMPLATE_CONTEXT_PROCESSORS = [
'django.contrib.auth.context_processors.auth',
'django.core.context_processors.debug',
'django.core.context_processors.media',
'django.core.context_processors.request',
'django.contrib.messages.context_processors.messages',
'django.core.context_processors.static',

'allauth.account.context_processors.account',
'allauth.socialaccount.context_processors.socialaccount',
]

# avoid deprecation warnings during tests
Expand Down
36 changes: 18 additions & 18 deletions dj_rest_auth/tests/urls.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from allauth.socialaccount.providers.facebook.views import FacebookOAuth2Adapter
from allauth.socialaccount.providers.twitter.views import TwitterOAuthAdapter
from django.conf.urls import include, url
from django.urls import include, re_path
from django.views.decorators.csrf import ensure_csrf_cookie
from django.views.generic import TemplateView
from rest_framework import permissions
Expand Down Expand Up @@ -74,30 +74,30 @@ def get_csrf_cookie(request):


urlpatterns += [
url(r'^rest-registration/', include('dj_rest_auth.registration.urls')),
url(r'^test-admin/', include(django_urls)),
url(
re_path(r'^rest-registration/', include('dj_rest_auth.registration.urls')),
re_path(r'^test-admin/', include(django_urls)),
re_path(
r'^account-email-verification-sent/$', TemplateView.as_view(),
name='account_email_verification_sent',
),
url(
re_path(
r'^account-confirm-email/(?P<key>[-:\w]+)/$', TemplateView.as_view(),
name='account_confirm_email',
),
url(r'^social-login/facebook/$', FacebookLogin.as_view(), name='fb_login'),
url(r'^social-login/twitter/$', TwitterLogin.as_view(), name='tw_login'),
url(r'^social-login/twitter-no-view/$', twitter_login_view, name='tw_login_no_view'),
url(r'^social-login/twitter-no-adapter/$', TwitterLoginNoAdapter.as_view(), name='tw_login_no_adapter'),
url(r'^social-login/facebook/connect/$', FacebookConnect.as_view(), name='fb_connect'),
url(r'^social-login/twitter/connect/$', TwitterConnect.as_view(), name='tw_connect'),
url(r'^socialaccounts/$', SocialAccountListView.as_view(), name='social_account_list'),
url(r'^protected-view/$', ExampleProtectedView.as_view()),
url(
re_path(r'^social-login/facebook/$', FacebookLogin.as_view(), name='fb_login'),
re_path(r'^social-login/twitter/$', TwitterLogin.as_view(), name='tw_login'),
re_path(r'^social-login/twitter-no-view/$', twitter_login_view, name='tw_login_no_view'),
re_path(r'^social-login/twitter-no-adapter/$', TwitterLoginNoAdapter.as_view(), name='tw_login_no_adapter'),
re_path(r'^social-login/facebook/connect/$', FacebookConnect.as_view(), name='fb_connect'),
re_path(r'^social-login/twitter/connect/$', TwitterConnect.as_view(), name='tw_connect'),
re_path(r'^socialaccounts/$', SocialAccountListView.as_view(), name='social_account_list'),
re_path(r'^protected-view/$', ExampleProtectedView.as_view()),
re_path(
r'^socialaccounts/(?P<pk>\d+)/disconnect/$', SocialAccountDisconnectView.as_view(),
name='social_account_disconnect',
),
url(r'^accounts/', include('allauth.socialaccount.urls')),
url(r'^getcsrf/', get_csrf_cookie, name='getcsrf'),
url('^token/verify/', TokenVerifyView.as_view(), name='token_verify'),
url('^token/refresh/', get_refresh_view().as_view(), name='token_refresh'),
re_path(r'^accounts/', include('allauth.socialaccount.urls')),
re_path(r'^getcsrf/', get_csrf_cookie, name='getcsrf'),
re_path('^token/verify/', TokenVerifyView.as_view(), name='token_verify'),
re_path('^token/refresh/', get_refresh_view().as_view(), name='token_refresh'),
]

0 comments on commit ea14056

Please sign in to comment.