Commit a32cd791 by Natalia

Ensure that we handle unicode everywhere.

parent 1a9fd76c
...@@ -27,11 +27,15 @@ ...@@ -27,11 +27,15 @@
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE. # POSSIBILITY OF SUCH DAMAGE.
from __future__ import unicode_literals
from urllib import urlencode from urllib import urlencode
from urlparse import parse_qsl, urlparse from urlparse import parse_qsl, urlparse
from django.conf import settings from django.conf import settings
from django.contrib import admin 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.models import Nonce, Association, UserOpenID
from django_openid_auth.store import DjangoOpenIDStore from django_openid_auth.store import DjangoOpenIDStore
...@@ -78,10 +82,6 @@ if original_admin_login is None: ...@@ -78,10 +82,6 @@ if original_admin_login is None:
original_admin_login = admin.sites.AdminSite.login 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): def _openid_login(instance, request, error_message='', extra_context=None):
# Support for allowing openid authentication for /admin # Support for allowing openid authentication for /admin
# (django.contrib.admin) # (django.contrib.admin)
......
...@@ -28,6 +28,8 @@ ...@@ -28,6 +28,8 @@
"""Glue between OpenID and django.contrib.auth.""" """Glue between OpenID and django.contrib.auth."""
from __future__ import unicode_literals
__metaclass__ = type __metaclass__ = type
import re import re
...@@ -166,7 +168,7 @@ class OpenIDBackend: ...@@ -166,7 +168,7 @@ class OpenIDBackend:
if len(split_names) == 2: if len(split_names) == 2:
first_name, last_name = split_names first_name, last_name = split_names
else: else:
first_name = u'' first_name = ''
last_name = fullname last_name = fullname
verification_scheme_map = getattr( verification_scheme_map = getattr(
...@@ -195,7 +197,8 @@ class OpenIDBackend: ...@@ -195,7 +197,8 @@ class OpenIDBackend:
if nickname is None or nickname == '': if nickname is None or nickname == '':
raise MissingUsernameViolation() 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' nickname = nickname or 'openiduser'
# See if we already have this nickname assigned to a username # See if we already have this nickname assigned to a username
......
...@@ -28,6 +28,8 @@ ...@@ -28,6 +28,8 @@
"""Exception classes thrown by OpenID Authentication and Validation.""" """Exception classes thrown by OpenID Authentication and Validation."""
from __future__ import unicode_literals
class DjangoOpenIDException(Exception): class DjangoOpenIDException(Exception):
pass pass
......
...@@ -27,6 +27,8 @@ ...@@ -27,6 +27,8 @@
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE. # POSSIBILITY OF SUCH DAMAGE.
from __future__ import unicode_literals
from django import forms from django import forms
from django.contrib.auth.admin import UserAdmin from django.contrib.auth.admin import UserAdmin
from django.contrib.auth.forms import UserChangeForm from django.contrib.auth.forms import UserChangeForm
......
...@@ -26,6 +26,8 @@ ...@@ -26,6 +26,8 @@
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE. # POSSIBILITY OF SUCH DAMAGE.
from __future__ import unicode_literals
from django.core.management.base import NoArgsCommand from django.core.management.base import NoArgsCommand
from django_openid_auth.store import DjangoOpenIDStore from django_openid_auth.store import DjangoOpenIDStore
......
...@@ -27,11 +27,10 @@ ...@@ -27,11 +27,10 @@
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE. # POSSIBILITY OF SUCH DAMAGE.
from django.contrib.auth.models import ( from __future__ import unicode_literals
Permission,
User,
)
from django.db import models from django.db import models
from django.contrib.auth.models import Permission, User
class Nonce(models.Model): class Nonce(models.Model):
......
...@@ -27,6 +27,8 @@ ...@@ -27,6 +27,8 @@
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE. # POSSIBILITY OF SUCH DAMAGE.
from __future__ import unicode_literals
import django.dispatch import django.dispatch
......
...@@ -27,6 +27,8 @@ ...@@ -27,6 +27,8 @@
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE. # POSSIBILITY OF SUCH DAMAGE.
from __future__ import unicode_literals
import base64 import base64
import time import time
......
...@@ -64,6 +64,8 @@ will be provided: ...@@ -64,6 +64,8 @@ will be provided:
@since: 2.1.1 @since: 2.1.1
""" """
from __future__ import unicode_literals
from openid import oidutil from openid import oidutil
from openid.extension import Extension from openid.extension import Extension
from openid.message import ( from openid.message import (
......
from __future__ import unicode_literals
from django.test.utils import override_settings from django.test.utils import override_settings
......
...@@ -28,6 +28,8 @@ ...@@ -28,6 +28,8 @@
"""Tests for the django_openid_auth Admin login form replacement.""" """Tests for the django_openid_auth Admin login form replacement."""
from __future__ import unicode_literals
from django.conf import settings from django.conf import settings
from django.contrib.auth.models import User from django.contrib.auth.models import User
...@@ -48,7 +50,7 @@ class SiteAdminTests(TestCase): ...@@ -48,7 +50,7 @@ class SiteAdminTests(TestCase):
staff member, then they get a failure response. staff member, then they get a failure response.
""" """
User.objects.create_user( 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') assert self.client.login(username='testing', password='test')
response = self.client.get('/admin/', follow=True) response = self.client.get('/admin/', follow=True)
self.assertContains( self.assertContains(
......
...@@ -26,6 +26,8 @@ ...@@ -26,6 +26,8 @@
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE. # POSSIBILITY OF SUCH DAMAGE.
from __future__ import unicode_literals
from django.contrib.auth.models import Group, Permission, User from django.contrib.auth.models import Group, Permission, User
from django.test import TestCase from django.test import TestCase
from django.test.utils import override_settings from django.test.utils import override_settings
......
...@@ -26,6 +26,8 @@ ...@@ -26,6 +26,8 @@
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE. # POSSIBILITY OF SUCH DAMAGE.
from __future__ import unicode_literals
from django.contrib.auth.models import User from django.contrib.auth.models import User
from django.test import TestCase from django.test import TestCase
......
# 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 unittest import skipIf
from django import VERSION from django import VERSION
......
...@@ -26,6 +26,8 @@ ...@@ -26,6 +26,8 @@
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE. # POSSIBILITY OF SUCH DAMAGE.
from __future__ import unicode_literals
import time import time
from django.test import TestCase from django.test import TestCase
......
...@@ -27,6 +27,8 @@ ...@@ -27,6 +27,8 @@
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE. # POSSIBILITY OF SUCH DAMAGE.
from __future__ import unicode_literals
import cgi import cgi
from urlparse import parse_qs from urlparse import parse_qs
...@@ -258,7 +260,7 @@ class RelyingPartyTests(TestCase): ...@@ -258,7 +260,7 @@ class RelyingPartyTests(TestCase):
response = self.client.post( response = self.client.post(
self.login_url, self.login_url,
{'openid_identifier': 'http://example.com/identity', {'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') self.assertContains(response, 'OpenID transaction in progress')
def test_login_no_next(self): def test_login_no_next(self):
......
...@@ -26,6 +26,8 @@ ...@@ -26,6 +26,8 @@
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE. # POSSIBILITY OF SUCH DAMAGE.
from __future__ import unicode_literals
from django.conf.urls import patterns, include from django.conf.urls import patterns, include
from django.http import HttpResponse from django.http import HttpResponse
......
...@@ -27,6 +27,8 @@ ...@@ -27,6 +27,8 @@
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE. # POSSIBILITY OF SUCH DAMAGE.
from __future__ import unicode_literals
from django.conf.urls import patterns, url from django.conf.urls import patterns, url
urlpatterns = patterns( urlpatterns = patterns(
......
...@@ -27,6 +27,8 @@ ...@@ -27,6 +27,8 @@
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE. # POSSIBILITY OF SUCH DAMAGE.
from __future__ import unicode_literals
import re import re
import urllib import urllib
from urlparse import urlsplit from urlparse import urlsplit
......
...@@ -39,4 +39,4 @@ deps = ...@@ -39,4 +39,4 @@ deps =
basepython = python2.7 basepython = python2.7
deps = deps =
django >= 1.8, < 1.9 django >= 1.8, < 1.9
{[testenv]deps} {[testenv]deps}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment