Merge lp:~ricardokirkner/django-openid-auth/support-django-1.10 into lp:django-openid-auth

Proposed by Ricardo Kirkner
Status: Merged
Approved by: Ricardo Kirkner
Approved revision: 131
Merged at revision: 124
Proposed branch: lp:~ricardokirkner/django-openid-auth/support-django-1.10
Merge into: lp:django-openid-auth
Diff against target: 333 lines (+104/-49)
9 files modified
django_openid_auth/templates/openid/login.html (+0/-1)
django_openid_auth/tests/test_views.py (+25/-9)
django_openid_auth/tests/urls.py (+5/-6)
django_openid_auth/urls.py (+12/-6)
django_openid_auth/views.py (+21/-14)
example_consumer/settings.py (+18/-0)
example_consumer/urls.py (+5/-5)
setup.py (+1/-1)
tox.ini (+17/-7)
To merge this branch: bzr merge lp:~ricardokirkner/django-openid-auth/support-django-1.10
Reviewer Review Type Date Requested Status
Fabián Ezequiel Gallina (community) Approve
Review via email: mp+314843@code.launchpad.net

Commit message

support django 1.7 to 1.10

To post a comment you must log in.
Revision history for this message
Fabián Ezequiel Gallina (fgallina) wrote :

this looks good, added a comment around the use of REQUEST.

Revision history for this message
Fabián Ezequiel Gallina (fgallina) :
Revision history for this message
Fabián Ezequiel Gallina (fgallina) wrote :

LGTM

review: Approve
Revision history for this message
Otto Co-Pilot (otto-copilot) wrote :

The attempt to merge lp:~ricardokirkner/django-openid-auth/support-django-1.10 into lp:django-openid-auth failed. Below is the output from the failed tests.

Warning: Permanently added '10.73.243.152' (ECDSA) to the list of known hosts.
Traceback (most recent call last):
  File "/usr/bin/tox", line 9, in <module>
    load_entry_point('tox==1.6.0', 'console_scripts', 'tox')()
  File "/usr/lib/python2.7/dist-packages/tox/_cmdline.py", line 25, in main
    config = parseconfig(args, 'tox')
  File "/usr/lib/python2.7/dist-packages/tox/_config.py", line 44, in parseconfig
    parseini(config, inipath)
  File "/usr/lib/python2.7/dist-packages/tox/_config.py", line 241, in __init__
    config.envlist = self._getenvlist(reader, toxsection)
  File "/usr/lib/python2.7/dist-packages/tox/_config.py", line 343, in _getenvlist
    envlist = reader.getlist(toxsection, "envlist", sep=",")
  File "/usr/lib/python2.7/dist-packages/tox/_config.py", line 413, in getlist
    s = self.getdefault(section, name, None)
  File "/usr/lib/python2.7/dist-packages/tox/_config.py", line 511, in getdefault
    x = self._replace(x)
  File "/usr/lib/python2.7/dist-packages/tox/_config.py", line 626, in _replace
    return rexpattern.sub(replace_func, x)
  File "/usr/lib/python2.7/dist-packages/tox/_config.py", line 617, in _replace_match_no_quote
    return self._replace_match(match, quote=False)
  File "/usr/lib/python2.7/dist-packages/tox/_config.py", line 612, in _replace_match
    return handler(match, quote)
  File "/usr/lib/python2.7/dist-packages/tox/_config.py", line 575, in _replace_substitution
    val = self._substitute_from_other_section(sub_key, quote)
  File "/usr/lib/python2.7/dist-packages/tox/_config.py", line 569, in _substitute_from_other_section
    "substitution key %r not found" % key)
tox.ConfigError: ConfigError: substitution key '1.7,1.8,1.9,1.10' not found

Revision history for this message
Otto Co-Pilot (otto-copilot) wrote :

The attempt to merge lp:~ricardokirkner/django-openid-auth/support-django-1.10 into lp:django-openid-auth failed. Below is the output from the failed tests.

GLOB sdist-make: /home/ubuntu/work/setup.py
py27-django1.7 create: /home/ubuntu/work/.tox/py27-django1.7
ERROR: InterpreterNotFound: py27: python2.7
py27-django1.8 create: /home/ubuntu/work/.tox/py27-django1.8
ERROR: InterpreterNotFound: py27: python2.7
py27-django1.9 create: /home/ubuntu/work/.tox/py27-django1.9
ERROR: InterpreterNotFound: py27: python2.7
py27-django1.10 create: /home/ubuntu/work/.tox/py27-django1.10
ERROR: InterpreterNotFound: py27: python2.7
___________________________________ summary ____________________________________
ERROR: py27-django1.7: InterpreterNotFound: py27: python2.7
ERROR: py27-django1.8: InterpreterNotFound: py27: python2.7
ERROR: py27-django1.9: InterpreterNotFound: py27: python2.7
ERROR: py27-django1.10: InterpreterNotFound: py27: python2.7

Warning: Permanently added '10.73.243.76' (ECDSA) to the list of known hosts.

131. By Ricardo Kirkner

fix basepython syntax for older tox

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'django_openid_auth/templates/openid/login.html'
2--- django_openid_auth/templates/openid/login.html 2013-06-24 17:20:54 +0000
3+++ django_openid_auth/templates/openid/login.html 2017-01-16 15:49:47 +0000
4@@ -1,5 +1,4 @@
5 {% load i18n %}
6-{% load url from future %}
7 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
8 <html>
9 <head>
10
11=== modified file 'django_openid_auth/tests/test_views.py'
12--- django_openid_auth/tests/test_views.py 2015-04-23 20:39:02 +0000
13+++ django_openid_auth/tests/test_views.py 2017-01-16 15:49:47 +0000
14@@ -38,6 +38,7 @@
15 from django.core.urlresolvers import reverse
16 from django.http import HttpRequest, HttpResponse
17 from django.test import TestCase
18+from django.test.client import RequestFactory
19 from django.test.utils import override_settings
20 from mock import patch
21 from openid.consumer.consumer import Consumer, SuccessResponse
22@@ -54,8 +55,9 @@
23 from django_openid_auth.models import UserOpenID
24 from django_openid_auth.tests.helpers import override_session_serializer
25 from django_openid_auth.views import (
26+ get_request_data,
27+ make_consumer,
28 sanitise_redirect_url,
29- make_consumer,
30 )
31 from django_openid_auth.signals import openid_login_complete
32 from django_openid_auth.store import DjangoOpenIDStore
33@@ -163,13 +165,6 @@
34 def build_absolute_uri(self):
35 return self.META['SCRIPT_NAME'] + self.request_path
36
37- def _combined_request(self):
38- request = {}
39- request.update(self.POST)
40- request.update(self.GET)
41- return request
42- REQUEST = property(_combined_request)
43-
44
45 @override_session_serializer
46 @override_settings(
47@@ -184,10 +179,10 @@
48 OPENID_SREG_REQUIRED_FIELDS=[],
49 OPENID_USE_EMAIL_FOR_USERNAME=False,
50 OPENID_VALID_VERIFICATION_SCHEMES={},
51+ ROOT_URLCONF='django_openid_auth.tests.urls',
52 )
53 class RelyingPartyTests(TestCase):
54
55- urls = 'django_openid_auth.tests.urls'
56 login_url = reverse('openid-login')
57
58 def setUp(self):
59@@ -1388,3 +1383,24 @@
60 self.assertEqual(url, sanitised)
61 else:
62 self.assertEqual(settings.LOGIN_REDIRECT_URL, sanitised)
63+
64+ def test_get_request_data_from_post(self):
65+ request = RequestFactory().post('/', data={'foo': 'bar'})
66+ data = get_request_data(request)
67+ self.assertEqual(dict(data), {'foo': ['bar']})
68+
69+ def test_get_request_data_from_get(self):
70+ request = RequestFactory().get('/', data={'foo': 'bar'})
71+ data = get_request_data(request)
72+ self.assertEqual(dict(data), {'foo': ['bar']})
73+
74+ def test_get_request_data_merged(self):
75+ request = RequestFactory().post('/?baz=42', data={'foo': 'bar'})
76+ data = get_request_data(request)
77+ self.assertEqual(dict(data), {'foo': ['bar'], 'baz': ['42']})
78+
79+ def test_get_request_data_override_order(self):
80+ request = RequestFactory().post('/?foo=42', data={'foo': 'bar'})
81+ data = get_request_data(request)
82+ self.assertEqual(dict(data), {'foo': ['42', 'bar']})
83+ self.assertEqual(data['foo'], 'bar')
84
85=== modified file 'django_openid_auth/tests/urls.py'
86--- django_openid_auth/tests/urls.py 2015-04-23 20:39:02 +0000
87+++ django_openid_auth/tests/urls.py 2017-01-16 15:49:47 +0000
88@@ -28,7 +28,7 @@
89
90 from __future__ import unicode_literals
91
92-from django.conf.urls import patterns, include
93+from django.conf.urls import include, url
94 from django.http import HttpResponse
95
96
97@@ -36,8 +36,7 @@
98 return HttpResponse(request.user.username)
99
100
101-urlpatterns = patterns(
102- '',
103- (r'^getuser/$', get_user),
104- (r'^openid/', include('django_openid_auth.urls')),
105-)
106+urlpatterns = [
107+ url(r'^getuser/$', get_user),
108+ url(r'^openid/', include('django_openid_auth.urls')),
109+]
110
111=== modified file 'django_openid_auth/urls.py'
112--- django_openid_auth/urls.py 2015-04-23 20:39:02 +0000
113+++ django_openid_auth/urls.py 2017-01-16 15:49:47 +0000
114@@ -29,11 +29,17 @@
115
116 from __future__ import unicode_literals
117
118-from django.conf.urls import patterns, url
119+from django.conf.urls import url
120
121-urlpatterns = patterns(
122- 'django_openid_auth.views',
123- url(r'^login/$', 'login_begin', name='openid-login'),
124- url(r'^complete/$', 'login_complete', name='openid-complete'),
125- url(r'^logo.gif$', 'logo', name='openid-logo'),
126+from django_openid_auth.views import (
127+ login_begin,
128+ login_complete,
129+ logo,
130 )
131+
132+
133+urlpatterns = [
134+ url(r'^login/$', login_begin, name='openid-login'),
135+ url(r'^complete/$', login_complete, name='openid-complete'),
136+ url(r'^logo.gif$', logo, name='openid-logo'),
137+]
138
139=== modified file 'django_openid_auth/views.py'
140--- django_openid_auth/views.py 2015-04-23 20:39:02 +0000
141+++ django_openid_auth/views.py 2017-01-16 15:49:47 +0000
142@@ -39,6 +39,7 @@
143 from django.contrib.auth.models import Group
144 from django.core.urlresolvers import reverse
145 from django.http import HttpResponse, HttpResponseRedirect
146+from django.http.request import QueryDict
147 from django.shortcuts import render_to_response
148 from django.template import RequestContext
149 from django.template.loader import render_to_string
150@@ -129,22 +130,27 @@
151 template_name='openid/failure.html',
152 exception=None):
153 """Render an error page to the user."""
154- data = render_to_string(
155- template_name, dict(message=message, exception=exception),
156- context_instance=RequestContext(request))
157+ context = RequestContext(request)
158+ context.update(dict(message=message, exception=exception))
159+ data = render_to_string(template_name, context)
160 return HttpResponse(data, status=status)
161
162
163 def parse_openid_response(request):
164 """Parse an OpenID response from a Django request."""
165- # Short cut if there is no request parameters.
166- # if len(request.REQUEST) == 0:
167- # return None
168-
169 current_url = request.build_absolute_uri()
170
171 consumer = make_consumer(request)
172- return consumer.complete(dict(request.REQUEST.items()), current_url)
173+ data = get_request_data(request)
174+ return consumer.complete(data, current_url)
175+
176+
177+def get_request_data(request):
178+ # simulate old request.REQUEST for backwards compatibility
179+ data = QueryDict(query_string=None, mutable=True)
180+ data.update(request.GET)
181+ data.update(request.POST)
182+ return data
183
184
185 def login_begin(request, template_name='openid/login.html',
186@@ -153,7 +159,8 @@
187 render_failure=default_render_failure,
188 redirect_field_name=REDIRECT_FIELD_NAME):
189 """Begin an OpenID login request, possibly asking for an identity URL."""
190- redirect_to = request.REQUEST.get(redirect_field_name, '')
191+ data = get_request_data(request)
192+ redirect_to = data.get(redirect_field_name, '')
193
194 # Get the OpenID URL to try. First see if we've been configured
195 # to use a fixed server URL.
196@@ -169,10 +176,9 @@
197
198 # Invalid or no form data:
199 if openid_url is None:
200- context = {'form': login_form, redirect_field_name: redirect_to}
201- return render_to_response(
202- template_name, context,
203- context_instance=RequestContext(request))
204+ context = RequestContext(request)
205+ context.update({'form': login_form, redirect_field_name: redirect_to})
206+ return render_to_response(template_name, context)
207
208 consumer = make_consumer(request)
209 try:
210@@ -277,7 +283,8 @@
211 @csrf_exempt
212 def login_complete(request, redirect_field_name=REDIRECT_FIELD_NAME,
213 render_failure=None):
214- redirect_to = request.REQUEST.get(redirect_field_name, '')
215+ data = get_request_data(request)
216+ redirect_to = data.get(redirect_field_name, '')
217 render_failure = (
218 render_failure or getattr(settings, 'OPENID_RENDER_FAILURE', None) or
219 default_render_failure)
220
221=== modified file 'example_consumer/settings.py'
222--- example_consumer/settings.py 2016-05-26 22:27:03 +0000
223+++ example_consumer/settings.py 2017-01-16 15:49:47 +0000
224@@ -54,6 +54,24 @@
225 DEBUG = True
226
227 TEMPLATE_DEBUG = True
228+TEMPLATES = [
229+ {
230+ 'BACKEND': 'django.template.backends.django.DjangoTemplates',
231+ 'DIRS': [],
232+ 'APP_DIRS': True,
233+ 'OPTIONS': {
234+ 'context_processors': [
235+ 'django.contrib.auth.context_processors.auth',
236+ 'django.template.context_processors.debug',
237+ 'django.template.context_processors.i18n',
238+ 'django.template.context_processors.media',
239+ 'django.template.context_processors.static',
240+ 'django.template.context_processors.tz',
241+ 'django.contrib.messages.context_processors.messages',
242+ ]
243+ }
244+ }
245+]
246
247 ALLOWED_HOSTS = []
248
249
250=== modified file 'example_consumer/urls.py'
251--- example_consumer/urls.py 2015-04-23 20:02:39 +0000
252+++ example_consumer/urls.py 2017-01-16 15:49:47 +0000
253@@ -27,20 +27,20 @@
254 # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
255 # POSSIBILITY OF SUCH DAMAGE.
256
257-from django.conf.urls import patterns, include, url
258+from django.conf.urls import include, url
259 from django.contrib import admin
260+from django.contrib.auth import views as auth_views
261
262 import views
263
264
265 admin.autodiscover()
266
267-urlpatterns = patterns(
268- '',
269+urlpatterns = [
270 url(r'^$', views.index),
271 url(r'^openid/', include('django_openid_auth.urls')),
272- url(r'^logout/$', 'django.contrib.auth.views.logout'),
273+ url(r'^logout/$', auth_views.logout),
274 url(r'^private/$', views.require_authentication),
275
276 url(r'^admin/', include(admin.site.urls)),
277-)
278+]
279
280=== modified file 'setup.py'
281--- setup.py 2016-09-12 13:14:55 +0000
282+++ setup.py 2017-01-16 15:49:47 +0000
283@@ -43,7 +43,7 @@
284
285
286 description, long_description = __doc__.split('\n\n', 1)
287-VERSION = '0.11'
288+VERSION = '0.12'
289
290 setup(
291 name='django-openid-auth',
292
293=== modified file 'tox.ini'
294--- tox.ini 2016-08-11 11:28:30 +0000
295+++ tox.ini 2017-01-16 15:49:47 +0000
296@@ -1,20 +1,30 @@
297 [tox]
298-envlist = py2.7-django1.7, py2.7-django1.8
299+envlist = py27-django1.7,py27-django1.8,py27-django1.9,py27-django1.10
300
301 [testenv]
302 commands = python manage.py test django_openid_auth
303+basepython =
304+ python2.7
305 deps=
306 mock
307 python-openid
308
309-[testenv:py2.7-django1.7]
310-basepython = python2.7
311+[testenv:py27-django1.7]
312 deps =
313 django == 1.7.11
314 {[testenv]deps}
315
316-[testenv:py2.7-django1.8]
317-basepython = python2.7
318-deps =
319- django == 1.8.14
320+[testenv:py27-django1.8]
321+deps =
322+ django == 1.8.17
323+ {[testenv]deps}
324+
325+[testenv:py27-django1.9]
326+deps =
327+ django == 1.9.12
328+ {[testenv]deps}
329+
330+[testenv:py27-django1.10]
331+deps =
332+ django == 1.10.5
333 {[testenv]deps}

Subscribers

People subscribed via source and target branches