aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNatalia <natalia.bidart@ubuntu.com>2015-04-23 17:39:02 -0300
committerNatalia <natalia.bidart@ubuntu.com>2015-04-23 17:39:02 -0300
commita32cd791d8b1ed970b4bbf2734fda75f1ae629a3 (patch)
tree21db460b4a2c14ade2d2449dcdcc9cfb4c2a18aa
parent1a9fd76c6e9090749271316550d15365ea73f96d (diff)
Ensure that we handle unicode everywhere.
-rw-r--r--django_openid_auth/admin.py8
-rw-r--r--django_openid_auth/auth.py7
-rw-r--r--django_openid_auth/exceptions.py2
-rw-r--r--django_openid_auth/forms.py2
-rw-r--r--django_openid_auth/management/commands/openid_cleanup.py2
-rw-r--r--django_openid_auth/models.py7
-rw-r--r--django_openid_auth/signals.py2
-rw-r--r--django_openid_auth/store.py2
-rw-r--r--django_openid_auth/teams.py2
-rw-r--r--django_openid_auth/tests/helpers.py2
-rw-r--r--django_openid_auth/tests/test_admin.py4
-rw-r--r--django_openid_auth/tests/test_auth.py2
-rw-r--r--django_openid_auth/tests/test_models.py2
-rw-r--r--django_openid_auth/tests/test_settings.py30
-rw-r--r--django_openid_auth/tests/test_store.py2
-rw-r--r--django_openid_auth/tests/test_views.py4
-rw-r--r--django_openid_auth/tests/urls.py2
-rw-r--r--django_openid_auth/urls.py2
-rw-r--r--django_openid_auth/views.py2
-rw-r--r--tox.ini2
20 files changed, 75 insertions, 13 deletions
diff --git a/django_openid_auth/admin.py b/django_openid_auth/admin.py
index b89cd8c..c1150fd 100644
--- a/django_openid_auth/admin.py
+++ b/django_openid_auth/admin.py
@@ -27,11 +27,15 @@
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
+from __future__ import unicode_literals
+
from urllib import urlencode
from urlparse import parse_qsl, urlparse
from django.conf import settings
from django.contrib import admin
+from django.http import HttpResponseRedirect
+from django_openid_auth import views
from django_openid_auth.models import Nonce, Association, UserOpenID
from django_openid_auth.store import DjangoOpenIDStore
@@ -78,10 +82,6 @@ if original_admin_login is None:
original_admin_login = admin.sites.AdminSite.login
-from django.http import HttpResponseRedirect
-from django_openid_auth import views
-
-
def _openid_login(instance, request, error_message='', extra_context=None):
# Support for allowing openid authentication for /admin
# (django.contrib.admin)
diff --git a/django_openid_auth/auth.py b/django_openid_auth/auth.py
index 6e8346c..faf46b8 100644
--- a/django_openid_auth/auth.py
+++ b/django_openid_auth/auth.py
@@ -28,6 +28,8 @@
"""Glue between OpenID and django.contrib.auth."""
+from __future__ import unicode_literals
+
__metaclass__ = type
import re
@@ -166,7 +168,7 @@ class OpenIDBackend:
if len(split_names) == 2:
first_name, last_name = split_names
else:
- first_name = u''
+ first_name = ''
last_name = fullname
verification_scheme_map = getattr(
@@ -195,7 +197,8 @@ class OpenIDBackend:
if nickname is None or nickname == '':
raise MissingUsernameViolation()
- # If we don't have a nickname, and we're not being strict, use default
+ # If we don't have a nickname, and we're not being strict, use a
+ # default
nickname = nickname or 'openiduser'
# See if we already have this nickname assigned to a username
diff --git a/django_openid_auth/exceptions.py b/django_openid_auth/exceptions.py
index 59a17cc..23eb560 100644
--- a/django_openid_auth/exceptions.py
+++ b/django_openid_auth/exceptions.py
@@ -28,6 +28,8 @@
"""Exception classes thrown by OpenID Authentication and Validation."""
+from __future__ import unicode_literals
+
class DjangoOpenIDException(Exception):
pass
diff --git a/django_openid_auth/forms.py b/django_openid_auth/forms.py
index bc1b0e5..88bbc50 100644
--- a/django_openid_auth/forms.py
+++ b/django_openid_auth/forms.py
@@ -27,6 +27,8 @@
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
+from __future__ import unicode_literals
+
from django import forms
from django.contrib.auth.admin import UserAdmin
from django.contrib.auth.forms import UserChangeForm
diff --git a/django_openid_auth/management/commands/openid_cleanup.py b/django_openid_auth/management/commands/openid_cleanup.py
index a5d3304..c2f779f 100644
--- a/django_openid_auth/management/commands/openid_cleanup.py
+++ b/django_openid_auth/management/commands/openid_cleanup.py
@@ -26,6 +26,8 @@
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
+from __future__ import unicode_literals
+
from django.core.management.base import NoArgsCommand
from django_openid_auth.store import DjangoOpenIDStore
diff --git a/django_openid_auth/models.py b/django_openid_auth/models.py
index eeee7db..083d8bc 100644
--- a/django_openid_auth/models.py
+++ b/django_openid_auth/models.py
@@ -27,11 +27,10 @@
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
-from django.contrib.auth.models import (
- Permission,
- User,
-)
+from __future__ import unicode_literals
+
from django.db import models
+from django.contrib.auth.models import Permission, User
class Nonce(models.Model):
diff --git a/django_openid_auth/signals.py b/django_openid_auth/signals.py
index 6f3a74b..e3b3d1d 100644
--- a/django_openid_auth/signals.py
+++ b/django_openid_auth/signals.py
@@ -27,6 +27,8 @@
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
+from __future__ import unicode_literals
+
import django.dispatch
diff --git a/django_openid_auth/store.py b/django_openid_auth/store.py
index 9ffb7ce..3c1c3e8 100644
--- a/django_openid_auth/store.py
+++ b/django_openid_auth/store.py
@@ -27,6 +27,8 @@
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
+from __future__ import unicode_literals
+
import base64
import time
diff --git a/django_openid_auth/teams.py b/django_openid_auth/teams.py
index addb692..ed84fe3 100644
--- a/django_openid_auth/teams.py
+++ b/django_openid_auth/teams.py
@@ -64,6 +64,8 @@ will be provided:
@since: 2.1.1
"""
+from __future__ import unicode_literals
+
from openid import oidutil
from openid.extension import Extension
from openid.message import (
diff --git a/django_openid_auth/tests/helpers.py b/django_openid_auth/tests/helpers.py
index b663c5b..f8fb0ae 100644
--- a/django_openid_auth/tests/helpers.py
+++ b/django_openid_auth/tests/helpers.py
@@ -1,3 +1,5 @@
+from __future__ import unicode_literals
+
from django.test.utils import override_settings
diff --git a/django_openid_auth/tests/test_admin.py b/django_openid_auth/tests/test_admin.py
index 45a43ec..a659a31 100644
--- a/django_openid_auth/tests/test_admin.py
+++ b/django_openid_auth/tests/test_admin.py
@@ -28,6 +28,8 @@
"""Tests for the django_openid_auth Admin login form replacement."""
+from __future__ import unicode_literals
+
from django.conf import settings
from django.contrib.auth.models import User
@@ -48,7 +50,7 @@ class SiteAdminTests(TestCase):
staff member, then they get a failure response.
"""
User.objects.create_user(
- username=u'testing', email='testing@example.com', password=u'test')
+ username='testing', email='testing@example.com', password='test')
assert self.client.login(username='testing', password='test')
response = self.client.get('/admin/', follow=True)
self.assertContains(
diff --git a/django_openid_auth/tests/test_auth.py b/django_openid_auth/tests/test_auth.py
index 1bfb087..b37bedd 100644
--- a/django_openid_auth/tests/test_auth.py
+++ b/django_openid_auth/tests/test_auth.py
@@ -26,6 +26,8 @@
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
+from __future__ import unicode_literals
+
from django.contrib.auth.models import Group, Permission, User
from django.test import TestCase
from django.test.utils import override_settings
diff --git a/django_openid_auth/tests/test_models.py b/django_openid_auth/tests/test_models.py
index 9616ff6..d9a48c8 100644
--- a/django_openid_auth/tests/test_models.py
+++ b/django_openid_auth/tests/test_models.py
@@ -26,6 +26,8 @@
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
+from __future__ import unicode_literals
+
from django.contrib.auth.models import User
from django.test import TestCase
diff --git a/django_openid_auth/tests/test_settings.py b/django_openid_auth/tests/test_settings.py
index a3fe015..cfcc176 100644
--- a/django_openid_auth/tests/test_settings.py
+++ b/django_openid_auth/tests/test_settings.py
@@ -1,3 +1,33 @@
+# django-openid-auth - OpenID integration for django.contrib.auth
+#
+# Copyright (C) 2013 Canonical Ltd.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+#
+# * Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+
+from __future__ import unicode_literals
+
from unittest import skipIf
from django import VERSION
diff --git a/django_openid_auth/tests/test_store.py b/django_openid_auth/tests/test_store.py
index 1a30e92..e5e1451 100644
--- a/django_openid_auth/tests/test_store.py
+++ b/django_openid_auth/tests/test_store.py
@@ -26,6 +26,8 @@
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
+from __future__ import unicode_literals
+
import time
from django.test import TestCase
diff --git a/django_openid_auth/tests/test_views.py b/django_openid_auth/tests/test_views.py
index 2fae406..835ddd5 100644
--- a/django_openid_auth/tests/test_views.py
+++ b/django_openid_auth/tests/test_views.py
@@ -27,6 +27,8 @@
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
+from __future__ import unicode_literals
+
import cgi
from urlparse import parse_qs
@@ -258,7 +260,7 @@ class RelyingPartyTests(TestCase):
response = self.client.post(
self.login_url,
{'openid_identifier': 'http://example.com/identity',
- 'next': u'/files/ñandú.jpg'.encode('utf-8')})
+ 'next': '/files/ñandú.jpg'.encode('utf-8')})
self.assertContains(response, 'OpenID transaction in progress')
def test_login_no_next(self):
diff --git a/django_openid_auth/tests/urls.py b/django_openid_auth/tests/urls.py
index 746ee56..d30e01d 100644
--- a/django_openid_auth/tests/urls.py
+++ b/django_openid_auth/tests/urls.py
@@ -26,6 +26,8 @@
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
+from __future__ import unicode_literals
+
from django.conf.urls import patterns, include
from django.http import HttpResponse
diff --git a/django_openid_auth/urls.py b/django_openid_auth/urls.py
index 34b311e..c984671 100644
--- a/django_openid_auth/urls.py
+++ b/django_openid_auth/urls.py
@@ -27,6 +27,8 @@
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
+from __future__ import unicode_literals
+
from django.conf.urls import patterns, url
urlpatterns = patterns(
diff --git a/django_openid_auth/views.py b/django_openid_auth/views.py
index 9244618..dc9c248 100644
--- a/django_openid_auth/views.py
+++ b/django_openid_auth/views.py
@@ -27,6 +27,8 @@
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
+from __future__ import unicode_literals
+
import re
import urllib
from urlparse import urlsplit
diff --git a/tox.ini b/tox.ini
index f436d18..f6c4518 100644
--- a/tox.ini
+++ b/tox.ini
@@ -39,4 +39,4 @@ deps =
basepython = python2.7
deps =
django >= 1.8, < 1.9
- {[testenv]deps} \ No newline at end of file
+ {[testenv]deps}