Merge lp:~fgallina/django-openid-auth/django16-compatibility into lp:~django-openid-auth/django-openid-auth/trunk

Proposed by Fabián Ezequiel Gallina
Status: Merged
Approved by: Ricardo Kirkner
Approved revision: 111
Merged at revision: 110
Proposed branch: lp:~fgallina/django-openid-auth/django16-compatibility
Merge into: lp:~django-openid-auth/django-openid-auth/trunk
Diff against target: 206 lines (+68/-9)
7 files modified
README.txt (+10/-5)
django_openid_auth/tests/__init__.py (+3/-2)
django_openid_auth/tests/helpers.py (+5/-0)
django_openid_auth/tests/test_auth.py (+3/-0)
django_openid_auth/tests/test_settings.py (+35/-0)
django_openid_auth/tests/test_views.py (+5/-1)
tox.ini (+7/-1)
To merge this branch: bzr merge lp:~fgallina/django-openid-auth/django16-compatibility
Reviewer Review Type Date Requested Status
Ricardo Kirkner Approve
Review via email: mp+216891@code.launchpad.net

Commit message

Django 1.6 compatibility

  + Added installation notes about the SESSION_SERIALIZER setting.
  + Included tox.ini section for Python 2.7 + Django 1.6.
  + New decorator override_session_serializer enforces pickle session
    serialization in tests.
  + Added test checking Django version defaults for
    SESSION_SERIALIZER.

To post a comment you must log in.
111. By Fabián Ezequiel Gallina

Add assertion to tests for clean OPENID_LAUNCHPAD_STAFF_TEAMS setting

Revision history for this message
Ricardo Kirkner (ricardokirkner) wrote :

LGTM

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'README.txt'
--- README.txt 2013-05-16 23:10:23 +0000
+++ README.txt 2014-04-23 14:34:39 +0000
@@ -8,13 +8,18 @@
88
9== Basic Installation ==9== Basic Installation ==
1010
11 1. Install the Jan Rain Python OpenID library. It can be found at:11 0. Install the Jan Rain Python OpenID library. It can be found at:
1212
13 http://openidenabled.com/python-openid/13 http://openidenabled.com/python-openid/
1414
15 It can also be found in most Linux distributions packaged as15 It can also be found in most Linux distributions packaged as
16 "python-openid". You will need version 2.2.0 or later.16 "python-openid". You will need version 2.2.0 or later.
1717
18 1. If you are using Django 1.6, configure your project to use the
19 pickle based session serializer:
20
21 SESSION_SERIALIZER = 'django.contrib.sessions.serializers.PickleSerializer'
22
18 2. Add 'django_openid_auth' to INSTALLED_APPS for your application.23 2. Add 'django_openid_auth' to INSTALLED_APPS for your application.
19 At a minimum, you'll need the following in there:24 At a minimum, you'll need the following in there:
2025
@@ -143,8 +148,8 @@
143148
144 OPENID_USE_AS_ADMIN_LOGIN = True149 OPENID_USE_AS_ADMIN_LOGIN = True
145150
146It is worth noting that a user needs to be be marked as a "staff user" to be able to access the admin interface. A new openid user will not normally be a "staff user". 151It is worth noting that a user needs to be be marked as a "staff user" to be able to access the admin interface. A new openid user will not normally be a "staff user".
147The easiest way to resolve this is to use traditional authentication (OPENID_USE_AS_ADMIN_LOGIN = False) to sign in as your first user with a password and authorise your 152The easiest way to resolve this is to use traditional authentication (OPENID_USE_AS_ADMIN_LOGIN = False) to sign in as your first user with a password and authorise your
148openid user to be staff.153openid user to be staff.
149154
150== Change Django usernames if the nickname changes on the provider ==155== Change Django usernames if the nickname changes on the provider ==
@@ -162,7 +167,7 @@
162If you must have a valid, unique nickname in order to create a user accont, add the following setting:167If you must have a valid, unique nickname in order to create a user accont, add the following setting:
163168
164 OPENID_STRICT_USERNAMES = True169 OPENID_STRICT_USERNAMES = True
165 170
166This will cause an OpenID login attempt to fail if the provider does not return a 'nickname' (username) for the user, or if the nickname conflicts with an existing user with a different openid identiy url.171This will cause an OpenID login attempt to fail if the provider does not return a 'nickname' (username) for the user, or if the nickname conflicts with an existing user with a different openid identiy url.
167Without this setting, logins without a nickname will be given the username 'openiduser', and upon conflicts with existing username, an incrementing number will be appended to the username until it is unique.172Without this setting, logins without a nickname will be given the username 'openiduser', and upon conflicts with existing username, an incrementing number will be appended to the username until it is unique.
168173
@@ -171,7 +176,7 @@
171If your users should use a physical multi-factor authentication method, such as RSA tokens or YubiKey, add the following setting:176If your users should use a physical multi-factor authentication method, such as RSA tokens or YubiKey, add the following setting:
172177
173 OPENID_PHYSICAL_MULTIFACTOR_REQUIRED = True178 OPENID_PHYSICAL_MULTIFACTOR_REQUIRED = True
174 179
175If the user's OpenID provider supports the PAPE extension and provides the Physical Multifactor authentication policy, this will180If the user's OpenID provider supports the PAPE extension and provides the Physical Multifactor authentication policy, this will
176cause the OpenID login to fail if the user does not provide valid physical authentication to the provider.181cause the OpenID login to fail if the user does not provide valid physical authentication to the provider.
177182
178183
=== modified file 'django_openid_auth/tests/__init__.py'
--- django_openid_auth/tests/__init__.py 2013-05-24 23:33:30 +0000
+++ django_openid_auth/tests/__init__.py 2014-04-23 14:34:39 +0000
@@ -28,6 +28,7 @@
2828
29import unittest29import unittest
30from test_views import *30from test_views import *
31from test_settings import *
31from test_store import *32from test_store import *
32from test_auth import *33from test_auth import *
33from test_admin import *34from test_admin import *
@@ -35,8 +36,8 @@
3536
36def suite():37def suite():
37 suite = unittest.TestSuite()38 suite = unittest.TestSuite()
38 for name in ['test_auth', 'test_models', 'test_store', 'test_views',39 for name in ['test_auth', 'test_models', 'test_settings', 'test_store',
39 'test_admin']:40 'test_views', 'test_admin']:
40 mod = __import__('%s.%s' % (__name__, name), {}, {}, ['suite'])41 mod = __import__('%s.%s' % (__name__, name), {}, {}, ['suite'])
41 suite.addTest(mod.suite())42 suite.addTest(mod.suite())
42 return suite43 return suite
4344
=== added file 'django_openid_auth/tests/helpers.py'
--- django_openid_auth/tests/helpers.py 1970-01-01 00:00:00 +0000
+++ django_openid_auth/tests/helpers.py 2014-04-23 14:34:39 +0000
@@ -0,0 +1,5 @@
1from django.test.utils import override_settings
2
3
4override_session_serializer = override_settings(
5 SESSION_SERIALIZER='django.contrib.sessions.serializers.PickleSerializer')
06
=== modified file 'django_openid_auth/tests/test_auth.py'
--- django_openid_auth/tests/test_auth.py 2013-06-21 17:48:28 +0000
+++ django_openid_auth/tests/test_auth.py 2014-04-23 14:34:39 +0000
@@ -39,6 +39,7 @@
39from django_openid_auth.auth import OpenIDBackend39from django_openid_auth.auth import OpenIDBackend
40from django_openid_auth.models import UserOpenID40from django_openid_auth.models import UserOpenID
41from django_openid_auth.teams import ns_uri as TEAMS_NS41from django_openid_auth.teams import ns_uri as TEAMS_NS
42from django_openid_auth.tests.helpers import override_session_serializer
42from openid.consumer.consumer import SuccessResponse43from openid.consumer.consumer import SuccessResponse
43from openid.consumer.discover import OpenIDServiceEndpoint44from openid.consumer.discover import OpenIDServiceEndpoint
44from openid.message import Message, OPENID2_NS45from openid.message import Message, OPENID2_NS
@@ -47,6 +48,8 @@
47SREG_NS = "http://openid.net/sreg/1.0"48SREG_NS = "http://openid.net/sreg/1.0"
48AX_NS = "http://openid.net/srv/ax/1.0"49AX_NS = "http://openid.net/srv/ax/1.0"
4950
51
52@override_session_serializer
50class OpenIDBackendTests(TestCase):53class OpenIDBackendTests(TestCase):
5154
52 def setUp(self):55 def setUp(self):
5356
=== added file 'django_openid_auth/tests/test_settings.py'
--- django_openid_auth/tests/test_settings.py 1970-01-01 00:00:00 +0000
+++ django_openid_auth/tests/test_settings.py 2014-04-23 14:34:39 +0000
@@ -0,0 +1,35 @@
1from unittest import skipIf, TestLoader
2
3from django import VERSION
4from django.conf import settings
5from django.test import TestCase
6
7
8class SessionSerializerTest(TestCase):
9 """Django 1.6 changed the default session serializer to use JSON
10 instead of pickle for security reasons[0]. Unfortunately the
11 openid module on which we rely stores objects which are not JSON
12 serializable[1], so until this is fixed upstream (or we decide to
13 create a wrapper serializer) we are recommending Django 1.6 users
14 to fallback to the PickleSerializer.
15
16 [0] https://bit.ly/1myzetd
17 [1] https://github.com/openid/python-openid/issues/17
18 """
19 @skipIf(VERSION >= (1, 6, 0), "Old versions used the pickle serializer.")
20 def test_not_using_json_session_serializer(self):
21 # We use getattr because this setting did not exist in Django
22 # 1.4 (pickle serialization was hard coded)
23 serializer = getattr(settings, 'SESSION_SERIALIZER', '')
24 self.assertNotEqual(
25 serializer, 'django.contrib.sessions.serializers.JSONSerializer')
26
27 @skipIf(VERSION < (1, 6, 0), "Newer versions use JSON by default.")
28 def test_using_json_session_serializer(self):
29 serializer = getattr(settings, 'SESSION_SERIALIZER', '')
30 self.assertEqual(
31 serializer, 'django.contrib.sessions.serializers.JSONSerializer')
32
33
34def suite():
35 return TestLoader().loadTestsFromName(__name__)
036
=== modified file 'django_openid_auth/tests/test_views.py'
--- django_openid_auth/tests/test_views.py 2013-06-21 17:24:18 +0000
+++ django_openid_auth/tests/test_views.py 2014-04-23 14:34:39 +0000
@@ -47,6 +47,7 @@
4747
48from django_openid_auth import teams48from django_openid_auth import teams
49from django_openid_auth.models import UserOpenID49from django_openid_auth.models import UserOpenID
50from django_openid_auth.tests.helpers import override_session_serializer
50from django_openid_auth.views import (51from django_openid_auth.views import (
51 sanitise_redirect_url,52 sanitise_redirect_url,
52 make_consumer,53 make_consumer,
@@ -161,6 +162,8 @@
161 return request162 return request
162 REQUEST = property(_combined_request)163 REQUEST = property(_combined_request)
163164
165
166@override_session_serializer
164class RelyingPartyTests(TestCase):167class RelyingPartyTests(TestCase):
165 urls = 'django_openid_auth.tests.urls'168 urls = 'django_openid_auth.tests.urls'
166169
@@ -1354,7 +1357,7 @@
1354 self.assertTrue(group3 not in user.groups.all())1357 self.assertTrue(group3 not in user.groups.all())
13551358
1356 def test_login_teams_staff_not_defined(self):1359 def test_login_teams_staff_not_defined(self):
1357 delattr(settings, 'OPENID_LAUNCHPAD_STAFF_TEAMS')1360 assert getattr(settings, 'OPENID_LAUNCHPAD_STAFF_TEAMS', None) is None
1358 user = User.objects.create_user('testuser', 'someone@example.com')1361 user = User.objects.create_user('testuser', 'someone@example.com')
1359 user.is_staff = True1362 user.is_staff = True
1360 user.save()1363 user.save()
@@ -1433,6 +1436,7 @@
1433 openid_login_complete.disconnect(login_callback)1436 openid_login_complete.disconnect(login_callback)
14341437
14351438
1439@override_session_serializer
1436class HelperFunctionsTest(TestCase):1440class HelperFunctionsTest(TestCase):
1437 def test_sanitise_redirect_url(self):1441 def test_sanitise_redirect_url(self):
1438 settings.ALLOWED_EXTERNAL_OPENID_REDIRECT_DOMAINS = [1442 settings.ALLOWED_EXTERNAL_OPENID_REDIRECT_DOMAINS = [
14391443
=== modified file 'tox.ini'
--- tox.ini 2014-04-22 19:24:28 +0000
+++ tox.ini 2014-04-23 14:34:39 +0000
@@ -1,6 +1,6 @@
1[tox]1[tox]
2envlist =2envlist =
3 py2.7-django1.4, py2.7-django1.53 py2.7-django1.4, py2.7-django1.5, py2.7-django1.6
44
5[testenv]5[testenv]
6commands = make check6commands = make check
@@ -17,3 +17,9 @@
17deps = django >= 1.5, < 1.617deps = django >= 1.5, < 1.6
18 python-openid18 python-openid
19 south19 south
20
21[testenv:py2.7-django1.6]
22basepython = python2.7
23deps = django >= 1.6, < 1.7
24 python-openid
25 south

Subscribers

People subscribed via source and target branches