Merge lp:~roadmr/canonical-identity-provider/fix-deprecation-warnings-3 into lp:canonical-identity-provider/release

Proposed by Daniel Manrique on 2018-05-30
Status: Merged
Approved by: Daniel Manrique on 2018-05-30
Approved revision: 1659
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: lp:~roadmr/canonical-identity-provider/fix-deprecation-warnings-3
Merge into: lp:canonical-identity-provider/release
Diff against target: 808 lines (+68/-62)
50 files modified
src/api/v10/tests/test_handlers.py (+1/-1)
src/api/v20/tests/test_auth.py (+1/-1)
src/api/v20/tests/test_decorators.py (+1/-1)
src/api/v20/tests/test_handlers.py (+2/-1)
src/api/v20/tests/test_login.py (+1/-1)
src/api/v20/tests/test_urls.py (+2/-1)
src/api/v20/tests/test_utils.py (+1/-1)
src/api/v20/utils.py (+1/-1)
src/identityprovider/admin.py (+1/-1)
src/identityprovider/emailutils.py (+1/-1)
src/identityprovider/forms.py (+1/-1)
src/identityprovider/middleware/useraccount.py (+1/-1)
src/identityprovider/middleware/xrds.py (+2/-1)
src/identityprovider/models/authtoken.py (+1/-1)
src/identityprovider/tests/helpers.py (+1/-1)
src/identityprovider/tests/openid_server/per_version/test_logout_during_login.py (+1/-1)
src/identityprovider/tests/openid_server/per_version/test_sso_workflow_authorize.py (+1/-1)
src/identityprovider/tests/sso_server/test_standalone_login.py (+1/-1)
src/identityprovider/tests/test_admin.py (+1/-1)
src/identityprovider/tests/test_emailutils.py (+1/-1)
src/identityprovider/tests/test_models_authtoken.py (+1/-1)
src/identityprovider/tests/test_readonly.py (+1/-1)
src/identityprovider/tests/test_signals.py (+1/-1)
src/identityprovider/tests/test_views_server.py (+1/-1)
src/identityprovider/tests/test_views_testing.py (+1/-1)
src/identityprovider/tests/test_xrds.py (+1/-1)
src/identityprovider/utils.py (+1/-1)
src/identityprovider/views/server.py (+1/-1)
src/identityprovider/widgets.py (+12/-10)
src/ubuntu_sso_saml/tests/test_processors.py (+1/-1)
src/ubuntu_sso_saml/tests/test_views.py (+1/-1)
src/ubuntu_sso_saml/views.py (+1/-1)
src/webui/decorators.py (+1/-1)
src/webui/tests/test_decorators.py (+2/-2)
src/webui/tests/test_templates.py (+1/-1)
src/webui/tests/test_views_account.py (+2/-1)
src/webui/tests/test_views_account_ssh.py (+1/-1)
src/webui/tests/test_views_auth_log.py (+1/-1)
src/webui/tests/test_views_consumer.py (+1/-1)
src/webui/tests/test_views_devices.py (+1/-1)
src/webui/tests/test_views_i18n.py (+1/-1)
src/webui/tests/test_views_registration.py (+1/-1)
src/webui/tests/test_views_ui.py (+3/-3)
src/webui/views/account.py (+1/-1)
src/webui/views/consumer.py (+1/-1)
src/webui/views/devices.py (+1/-1)
src/webui/views/errors.py (+1/-1)
src/webui/views/i18n.py (+1/-1)
src/webui/views/registration.py (+1/-1)
src/webui/views/ui.py (+1/-1)
To merge this branch: bzr merge lp:~roadmr/canonical-identity-provider/fix-deprecation-warnings-3
Reviewer Review Type Date Requested Status
Maximiliano Bertacchini 2018-05-30 Approve on 2018-05-30
Review via email: mp+347154@code.launchpad.net

Commit message

Fix most remaining Django and Python deprecation warnings in the sso codebase itself.

Some of the remaining ones probably need fixing in dependencies:
- django-statsd
- django-openid-auth
- django-piston
- django-honeypot
- raven
- preflight
- oauthlib

Other than the ones from dependencies, the remaining deprecation warnings are:

- most of the middlewares. RemovedInDjango20Warning: Old-style middleware using settings.MIDDLEWARE_CLASSES is deprecated. Update your middleware and use settings.MIDDLEWARE instead.
- identityprovider/models/twofactor.py:103: RemovedInDjango20Warning: Using user.is_authenticated() and user.is_anonymous() as a method is deprecated. Remove the parentheses to use it as an attribute. This needs updating django-openid-auth to make its is_authenticated method an attribute, to avoid ugly "is it callable?" logic in SSO itself.

Description of the change

Fix most remaining Django and Python deprecation warnings in the sso codebase itself.

Some of the remaining ones probably need fixing in dependencies:
- django-statsd
- django-openid-auth
- django-piston
- django-honeypot
- raven
- preflight
- oauthlib

Other than the ones from dependencies, the remaining deprecation warnings are:

- most of the middlewares. RemovedInDjango20Warning: Old-style middleware using settings.MIDDLEWARE_CLASSES is deprecated. Update your middleware and use settings.MIDDLEWARE instead.
- identityprovider/models/twofactor.py:103: RemovedInDjango20Warning: Using user.is_authenticated() and user.is_anonymous() as a method is deprecated. Remove the parentheses to use it as an attribute. This needs updating django-openid-auth to make its is_authenticated method an attribute, to avoid ugly "is it callable?" logic in SSO itself.

To post a comment you must log in.
Maximiliano Bertacchini (maxiberta) wrote :

+1, thanks!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/api/v10/tests/test_handlers.py'
--- src/api/v10/tests/test_handlers.py 2018-02-09 20:56:16 +0000
+++ src/api/v10/tests/test_handlers.py 2018-05-30 16:21:15 +0000
@@ -9,8 +9,8 @@
99
10from django.conf import settings10from django.conf import settings
11from django.core import mail11from django.core import mail
12from django.core.urlresolvers import reverse
13from django.test.utils import override_settings12from django.test.utils import override_settings
13from django.urls import reverse
14from django.utils.http import urlencode14from django.utils.http import urlencode
15from django.utils.timezone import now15from django.utils.timezone import now
16from gargoyle.testutils import switches16from gargoyle.testutils import switches
1717
=== modified file 'src/api/v20/tests/test_auth.py'
--- src/api/v20/tests/test_auth.py 2018-02-09 20:56:16 +0000
+++ src/api/v20/tests/test_auth.py 2018-05-30 16:21:15 +0000
@@ -5,8 +5,8 @@
5import json5import json
6from urllib import urlencode6from urllib import urlencode
77
8from django.core.urlresolvers import reverse
9from django.test.client import RequestFactory8from django.test.client import RequestFactory
9from django.urls import reverse
10from piston.handler import AnonymousBaseHandler10from piston.handler import AnonymousBaseHandler
11from piston.resource import Resource11from piston.resource import Resource
1212
1313
=== modified file 'src/api/v20/tests/test_decorators.py'
--- src/api/v20/tests/test_decorators.py 2018-02-14 14:05:59 +0000
+++ src/api/v20/tests/test_decorators.py 2018-05-30 16:21:15 +0000
@@ -4,8 +4,8 @@
44
5from django.conf.urls import url5from django.conf.urls import url
6from django.core.cache import cache6from django.core.cache import cache
7from django.core.urlresolvers import reverse
8from django.test import override_settings7from django.test import override_settings
8from django.urls import reverse
9from memcache import Client9from memcache import Client
10from piston.handler import BaseHandler10from piston.handler import BaseHandler
11from piston.resource import Resource11from piston.resource import Resource
1212
=== modified file 'src/api/v20/tests/test_handlers.py'
--- src/api/v20/tests/test_handlers.py 2018-02-14 14:05:59 +0000
+++ src/api/v20/tests/test_handlers.py 2018-05-30 16:21:15 +0000
@@ -16,9 +16,10 @@
16from django.contrib.auth.models import AnonymousUser16from django.contrib.auth.models import AnonymousUser
17from django.core import mail17from django.core import mail
18from django.core.serializers.json import DjangoJSONEncoder18from django.core.serializers.json import DjangoJSONEncoder
19from django.core.urlresolvers import NoReverseMatch, reverse
20from django.test.client import RequestFactory19from django.test.client import RequestFactory
21from django.test.utils import override_settings20from django.test.utils import override_settings
21from django.urls import reverse
22from django.urls.exceptions import NoReverseMatch
22from django.utils.timezone import now23from django.utils.timezone import now
23from gargoyle.testutils import switches24from gargoyle.testutils import switches
24from mock import Mock, patch25from mock import Mock, patch
2526
=== modified file 'src/api/v20/tests/test_login.py'
--- src/api/v20/tests/test_login.py 2018-02-21 11:59:00 +0000
+++ src/api/v20/tests/test_login.py 2018-05-30 16:21:15 +0000
@@ -2,7 +2,7 @@
22
3from django.contrib.auth.hashers import make_password3from django.contrib.auth.hashers import make_password
4from django.core.serializers.json import DjangoJSONEncoder4from django.core.serializers.json import DjangoJSONEncoder
5from django.core.urlresolvers import reverse5from django.urls import reverse
6from django.utils.timezone import now6from django.utils.timezone import now
7from timeline import Timeline7from timeline import Timeline
88
99
=== modified file 'src/api/v20/tests/test_urls.py'
--- src/api/v20/tests/test_urls.py 2016-06-08 05:03:11 +0000
+++ src/api/v20/tests/test_urls.py 2018-05-30 16:21:15 +0000
@@ -1,4 +1,5 @@
1from django.core.urlresolvers import resolve, reverse1from django.urls import reverse
2from django.urls.base import resolve
2from piston.authentication import NoAuthentication3from piston.authentication import NoAuthentication
34
4from api.v20 import auth, handlers5from api.v20 import auth, handlers
56
=== modified file 'src/api/v20/tests/test_utils.py'
--- src/api/v20/tests/test_utils.py 2018-01-27 13:11:38 +0000
+++ src/api/v20/tests/test_utils.py 2018-05-30 16:21:15 +0000
@@ -3,7 +3,7 @@
3from functools import partial3from functools import partial
4from operator import attrgetter4from operator import attrgetter
55
6from django.core.urlresolvers import reverse6from django.urls import reverse
77
8from api.v20.utils import (8from api.v20.utils import (
9 EnsureJSONResponseOnAPIErrorMiddleware,9 EnsureJSONResponseOnAPIErrorMiddleware,
1010
=== modified file 'src/api/v20/utils.py'
--- src/api/v20/utils.py 2018-02-09 14:17:25 +0000
+++ src/api/v20/utils.py 2018-05-30 16:21:15 +0000
@@ -4,8 +4,8 @@
4import json4import json
5from operator import attrgetter5from operator import attrgetter
66
7from django.core.urlresolvers import reverse
8from django.http import HttpResponse7from django.http import HttpResponse
8from django.urls import reverse
9from django.utils.translation import ugettext_lazy as _9from django.utils.translation import ugettext_lazy as _
1010
11from identityprovider.models.account import Account11from identityprovider.models.account import Account
1212
=== modified file 'src/identityprovider/admin.py'
--- src/identityprovider/admin.py 2018-05-29 17:14:24 +0000
+++ src/identityprovider/admin.py 2018-05-30 16:21:15 +0000
@@ -14,10 +14,10 @@
14from django.contrib.auth.hashers import make_password14from django.contrib.auth.hashers import make_password
15from django.contrib.auth.models import User15from django.contrib.auth.models import User
16from django.core import validators16from django.core import validators
17from django.core.urlresolvers import reverse
18from django.db import connections17from django.db import connections
19from django.db.models.query import QuerySet18from django.db.models.query import QuerySet
20from django.template.defaultfilters import force_escape19from django.template.defaultfilters import force_escape
20from django.urls import reverse
21from django.utils.html import format_html21from django.utils.html import format_html
22from oauth_backend.models import Consumer as V1Consumer, Token as V1Token22from oauth_backend.models import Consumer as V1Consumer, Token as V1Token
2323
2424
=== modified file 'src/identityprovider/emailutils.py'
--- src/identityprovider/emailutils.py 2018-04-04 15:35:18 +0000
+++ src/identityprovider/emailutils.py 2018-05-30 16:21:15 +0000
@@ -6,8 +6,8 @@
66
7from django.conf import settings7from django.conf import settings
8from django.core.mail import send_mail8from django.core.mail import send_mail
9from django.core.urlresolvers import reverse
10from django.template.loader import render_to_string9from django.template.loader import render_to_string
10from django.urls import reverse
11from django.utils.timezone import now11from django.utils.timezone import now
12from django.utils.translation import ugettext_lazy as _12from django.utils.translation import ugettext_lazy as _
1313
1414
=== modified file 'src/identityprovider/forms.py'
--- src/identityprovider/forms.py 2018-05-25 21:47:30 +0000
+++ src/identityprovider/forms.py 2018-05-30 16:21:15 +0000
@@ -6,8 +6,8 @@
66
7from django import forms7from django import forms
8from django.conf import settings8from django.conf import settings
9from django.core.urlresolvers import reverse
10from django.forms import Form, fields, widgets9from django.forms import Form, fields, widgets
10from django.urls import reverse
11from django.utils import translation11from django.utils import translation
12from django.utils.translation import ugettext_lazy as _12from django.utils.translation import ugettext_lazy as _
13from gargoyle import gargoyle13from gargoyle import gargoyle
1414
=== modified file 'src/identityprovider/middleware/useraccount.py'
--- src/identityprovider/middleware/useraccount.py 2016-06-08 17:05:05 +0000
+++ src/identityprovider/middleware/useraccount.py 2018-05-30 16:21:15 +0000
@@ -41,7 +41,7 @@
41 logout(request)41 logout(request)
4242
43 def process_request(self, request):43 def process_request(self, request):
44 if request.user.is_authenticated():44 if request.user.is_authenticated:
45 is_admin_url = self.is_admin_area(request.get_full_path())45 is_admin_url = self.is_admin_area(request.get_full_path())
46 if isinstance(request.user, User) and not is_admin_url:46 if isinstance(request.user, User) and not is_admin_url:
47 try:47 try:
4848
=== modified file 'src/identityprovider/middleware/xrds.py'
--- src/identityprovider/middleware/xrds.py 2018-02-09 20:56:16 +0000
+++ src/identityprovider/middleware/xrds.py 2018-05-30 16:21:15 +0000
@@ -3,10 +3,11 @@
33
4from urlparse import urlparse4from urlparse import urlparse
55
6from django.core.urlresolvers import resolve, reverse
7from django.http import Http404, HttpResponse6from django.http import Http404, HttpResponse
8from django.shortcuts import get_object_or_4047from django.shortcuts import get_object_or_404
9from django.template.loader import render_to_string8from django.template.loader import render_to_string
9from django.urls import reverse
10from django.urls.base import resolve
1011
11from openid.yadis.accept import getAcceptable12from openid.yadis.accept import getAcceptable
12from openid.yadis.constants import YADIS_CONTENT_TYPE, YADIS_HEADER_NAME13from openid.yadis.constants import YADIS_CONTENT_TYPE, YADIS_HEADER_NAME
1314
=== modified file 'src/identityprovider/models/authtoken.py'
--- src/identityprovider/models/authtoken.py 2018-05-25 16:27:25 +0000
+++ src/identityprovider/models/authtoken.py 2018-05-30 16:21:15 +0000
@@ -8,10 +8,10 @@
88
9from hashlib import sha2569from hashlib import sha256
1010
11from django.core.urlresolvers import reverse
12from django.core.validators import validate_email11from django.core.validators import validate_email
13from django.db import models12from django.db import models
14from django.http import Http40413from django.http import Http404
14from django.urls import reverse
15from django.utils.timezone import now15from django.utils.timezone import now
1616
17from identityprovider.models.account import (17from identityprovider.models.account import (
1818
=== modified file 'src/identityprovider/tests/helpers.py'
--- src/identityprovider/tests/helpers.py 2018-02-20 17:13:36 +0000
+++ src/identityprovider/tests/helpers.py 2018-05-30 16:21:15 +0000
@@ -7,7 +7,7 @@
77
8from django.contrib.auth.models import User8from django.contrib.auth.models import User
9from django.core import mail9from django.core import mail
10from django.core.urlresolvers import reverse10from django.urls import reverse
11from openid import fetchers11from openid import fetchers
12from openid.consumer.consumer import Consumer12from openid.consumer.consumer import Consumer
13from openid.consumer.discover import (13from openid.consumer.discover import (
1414
=== modified file 'src/identityprovider/tests/openid_server/per_version/test_logout_during_login.py'
--- src/identityprovider/tests/openid_server/per_version/test_logout_during_login.py 2013-11-12 15:30:36 +0000
+++ src/identityprovider/tests/openid_server/per_version/test_logout_during_login.py 2018-05-30 16:21:15 +0000
@@ -1,4 +1,4 @@
1from django.core.urlresolvers import reverse1from django.urls import reverse
22
3from identityprovider.tests.helpers import OpenIDTestCase3from identityprovider.tests.helpers import OpenIDTestCase
44
55
=== modified file 'src/identityprovider/tests/openid_server/per_version/test_sso_workflow_authorize.py'
--- src/identityprovider/tests/openid_server/per_version/test_sso_workflow_authorize.py 2013-04-01 15:24:48 +0000
+++ src/identityprovider/tests/openid_server/per_version/test_sso_workflow_authorize.py 2018-05-30 16:21:15 +0000
@@ -1,4 +1,4 @@
1from django.core.urlresolvers import reverse1from django.urls import reverse
22
3from identityprovider.models import OpenIDRPSummary3from identityprovider.models import OpenIDRPSummary
4from identityprovider.tests.helpers import OpenIDTestCase4from identityprovider.tests.helpers import OpenIDTestCase
55
=== modified file 'src/identityprovider/tests/sso_server/test_standalone_login.py'
--- src/identityprovider/tests/sso_server/test_standalone_login.py 2018-02-09 20:56:16 +0000
+++ src/identityprovider/tests/sso_server/test_standalone_login.py 2018-05-30 16:21:15 +0000
@@ -1,4 +1,4 @@
1from django.core.urlresolvers import reverse1from django.urls import reverse
22
3from identityprovider.models.account import Account3from identityprovider.models.account import Account
4from identityprovider.tests import DEFAULT_USER_PASSWORD4from identityprovider.tests import DEFAULT_USER_PASSWORD
55
=== modified file 'src/identityprovider/tests/test_admin.py'
--- src/identityprovider/tests/test_admin.py 2018-05-29 17:14:24 +0000
+++ src/identityprovider/tests/test_admin.py 2018-05-30 16:21:15 +0000
@@ -14,8 +14,8 @@
14)14)
15from django.contrib.auth.hashers import check_password15from django.contrib.auth.hashers import check_password
16from django.contrib.auth.models import User16from django.contrib.auth.models import User
17from django.core.urlresolvers import reverse
18from django.db import connections17from django.db import connections
18from django.urls import reverse
19from django.utils.dateformat import format19from django.utils.dateformat import format
20from django.utils.timezone import now20from django.utils.timezone import now
21from mock import MagicMock, Mock, patch21from mock import MagicMock, Mock, patch
2222
=== modified file 'src/identityprovider/tests/test_emailutils.py'
--- src/identityprovider/tests/test_emailutils.py 2017-05-09 18:02:49 +0000
+++ src/identityprovider/tests/test_emailutils.py 2018-05-30 16:21:15 +0000
@@ -8,9 +8,9 @@
88
9from django.conf import settings9from django.conf import settings
10from django.core import mail10from django.core import mail
11from django.core.urlresolvers import reverse
12from django.template.loader import render_to_string11from django.template.loader import render_to_string
13from django.test.utils import override_settings12from django.test.utils import override_settings
13from django.urls import reverse
14from django.utils.timezone import now14from django.utils.timezone import now
15from mock import patch15from mock import patch
1616
1717
=== modified file 'src/identityprovider/tests/test_models_authtoken.py'
--- src/identityprovider/tests/test_models_authtoken.py 2018-02-09 20:56:16 +0000
+++ src/identityprovider/tests/test_models_authtoken.py 2018-05-30 16:21:15 +0000
@@ -6,9 +6,9 @@
66
7from django.conf import settings7from django.conf import settings
8from django.core.exceptions import MultipleObjectsReturned, ValidationError8from django.core.exceptions import MultipleObjectsReturned, ValidationError
9from django.core.urlresolvers import reverse
10from django.http import Http4049from django.http import Http404
11from django.test.utils import override_settings10from django.test.utils import override_settings
11from django.urls import reverse
12from django.utils.timezone import now12from django.utils.timezone import now
13from mock import patch13from mock import patch
1414
1515
=== modified file 'src/identityprovider/tests/test_readonly.py'
--- src/identityprovider/tests/test_readonly.py 2018-02-09 20:56:16 +0000
+++ src/identityprovider/tests/test_readonly.py 2018-05-30 16:21:15 +0000
@@ -10,7 +10,7 @@
10import requests10import requests
11import responses11import responses
12from django.conf import settings12from django.conf import settings
13from django.core.urlresolvers import reverse13from django.urls import reverse
1414
15from identityprovider.readonly import (15from identityprovider.readonly import (
16 ReadOnlyManager,16 ReadOnlyManager,
1717
=== modified file 'src/identityprovider/tests/test_signals.py'
--- src/identityprovider/tests/test_signals.py 2018-01-23 17:51:11 +0000
+++ src/identityprovider/tests/test_signals.py 2018-05-30 16:21:15 +0000
@@ -5,11 +5,11 @@
55
6from django.conf import settings6from django.conf import settings
7from django.contrib.auth.signals import user_logged_in7from django.contrib.auth.signals import user_logged_in
8from django.core.urlresolvers import reverse
9from django.db.models.signals import (8from django.db.models.signals import (
10 post_save,9 post_save,
11 pre_delete,10 pre_delete,
12)11)
12from django.urls import reverse
13from django.utils.timezone import now13from django.utils.timezone import now
1414
15from mock import Mock, patch15from mock import Mock, patch
1616
=== modified file 'src/identityprovider/tests/test_views_server.py'
--- src/identityprovider/tests/test_views_server.py 2018-02-20 17:12:17 +0000
+++ src/identityprovider/tests/test_views_server.py 2018-05-30 16:21:15 +0000
@@ -12,9 +12,9 @@
12from django.contrib import messages12from django.contrib import messages
13from django.contrib.auth.models import AnonymousUser13from django.contrib.auth.models import AnonymousUser
14from django.core.cache import cache14from django.core.cache import cache
15from django.core.urlresolvers import reverse
16from django.http import HttpRequest15from django.http import HttpRequest
17from django.test.utils import override_settings, patch_logger16from django.test.utils import override_settings, patch_logger
17from django.urls import reverse
18from django.utils.timezone import now18from django.utils.timezone import now
19from gargoyle.testutils import switches19from gargoyle.testutils import switches
20from mock import Mock20from mock import Mock
2121
=== modified file 'src/identityprovider/tests/test_views_testing.py'
--- src/identityprovider/tests/test_views_testing.py 2018-02-09 20:56:16 +0000
+++ src/identityprovider/tests/test_views_testing.py 2018-05-30 16:21:15 +0000
@@ -2,8 +2,8 @@
2# GNU Affero General Public License version 3 (see the file LICENSE).2# GNU Affero General Public License version 3 (see the file LICENSE).
33
4from django.conf import settings4from django.conf import settings
5from django.core.urlresolvers import reverse
6from django.test.utils import patch_logger5from django.test.utils import patch_logger
6from django.urls import reverse
77
8from identityprovider.tests.utils import SSOBaseTestCase8from identityprovider.tests.utils import SSOBaseTestCase
9from identityprovider.views.testing import (9from identityprovider.views.testing import (
1010
=== modified file 'src/identityprovider/tests/test_xrds.py'
--- src/identityprovider/tests/test_xrds.py 2018-02-09 20:56:16 +0000
+++ src/identityprovider/tests/test_xrds.py 2018-05-30 16:21:15 +0000
@@ -1,8 +1,8 @@
1# Copyright 2010 Canonical Ltd. This software is licensed under the1# Copyright 2010 Canonical Ltd. This software is licensed under the
2# GNU Affero General Public License version 3 (see the file LICENSE).2# GNU Affero General Public License version 3 (see the file LICENSE).
33
4from django.core.urlresolvers import reverse
5from django.test.utils import override_settings, patch_logger4from django.test.utils import override_settings, patch_logger
5from django.urls import reverse
66
7from identityprovider.tests.utils import SSOBaseTestCase7from identityprovider.tests.utils import SSOBaseTestCase
88
99
=== modified file 'src/identityprovider/utils.py'
--- src/identityprovider/utils.py 2018-01-27 13:11:38 +0000
+++ src/identityprovider/utils.py 2018-05-30 16:21:15 +0000
@@ -15,9 +15,9 @@
15from django.conf import settings15from django.conf import settings
16from django.contrib.sessions.models import Session16from django.contrib.sessions.models import Session
17from django.core.exceptions import ObjectDoesNotExist17from django.core.exceptions import ObjectDoesNotExist
18from django.core.urlresolvers import reverse
19from django.db import connection, transaction18from django.db import connection, transaction
20from django.db.utils import ProgrammingError19from django.db.utils import ProgrammingError
20from django.urls import reverse
21from django.utils.translation import ugettext_lazy as _21from django.utils.translation import ugettext_lazy as _
2222
23SALT_LENGTH = 2023SALT_LENGTH = 20
2424
=== modified file 'src/identityprovider/views/server.py'
--- src/identityprovider/views/server.py 2018-05-25 20:41:26 +0000
+++ src/identityprovider/views/server.py 2018-05-30 16:21:15 +0000
@@ -10,7 +10,6 @@
1010
11from django.conf import settings11from django.conf import settings
12from django.contrib import auth, messages12from django.contrib import auth, messages
13from django.core.urlresolvers import reverse
14from django.http import (13from django.http import (
15 Http404,14 Http404,
16 HttpResponse,15 HttpResponse,
@@ -20,6 +19,7 @@
20)19)
21from django.shortcuts import get_object_or_404, render20from django.shortcuts import get_object_or_404, render
22from django.template import loader21from django.template import loader
22from django.urls import reverse
23from django.utils import translation23from django.utils import translation
24from django.utils.decorators import decorator_from_middleware24from django.utils.decorators import decorator_from_middleware
25from django.utils.timezone import now25from django.utils.timezone import now
2626
=== modified file 'src/identityprovider/widgets.py'
--- src/identityprovider/widgets.py 2018-05-28 17:05:47 +0000
+++ src/identityprovider/widgets.py 2018-05-30 16:21:15 +0000
@@ -30,15 +30,16 @@
3030
3131
32class ROAwareTextInput(TextInput):32class ROAwareTextInput(TextInput):
33 def render(self, name, value, attrs=None):33 def render(self, name, value, attrs=None, renderer=None):
34 if settings.READ_ONLY_MODE:34 if settings.READ_ONLY_MODE:
35 return read_only_markup(value)35 return read_only_markup(value)
36 else:36 else:
37 return super(ROAwareTextInput, self).render(name, value, attrs)37 return super(ROAwareTextInput, self).render(
38 name, value, attrs, renderer)
3839
3940
40class ROAwareSelect(Select):41class ROAwareSelect(Select):
41 def render(self, name, value, attrs=None):42 def render(self, name, value, attrs=None, renderer=None):
42 if settings.READ_ONLY_MODE:43 if settings.READ_ONLY_MODE:
43 label = ''44 label = ''
44 for option_value, option_label in self.choices:45 for option_value, option_label in self.choices:
@@ -47,11 +48,12 @@
47 break48 break
48 return read_only_markup(label)49 return read_only_markup(label)
49 else:50 else:
50 return super(ROAwareSelect, self).render(name, value, attrs)51 return super(ROAwareSelect, self).render(
52 name, value, attrs, renderer)
5153
5254
53class CommaSeparatedWidget(CheckboxSelectMultiple):55class CommaSeparatedWidget(CheckboxSelectMultiple):
54 def render(self, name, value, attrs=None):56 def render(self, name, value, attrs=None, renderer=None):
55 if value is None:57 if value is None:
56 value = ''58 value = ''
57 if isinstance(value, list):59 if isinstance(value, list):
@@ -59,14 +61,14 @@
59 else:61 else:
60 vals = value.split(',')62 vals = value.split(',')
61 return super(CommaSeparatedWidget, self).render(63 return super(CommaSeparatedWidget, self).render(
62 name, vals, attrs)64 name, vals, attrs, renderer)
6365
6466
65class StatusWidget(Select):67class StatusWidget(Select):
66 date_status_set = None68 date_status_set = None
6769
68 def render(self, name, value, attrs=None):70 def render(self, name, value, attrs=None, renderer=None):
69 select = super(StatusWidget, self).render(name, value, attrs)71 select = super(StatusWidget, self).render(name, value, attrs, renderer)
70 if self.date_status_set:72 if self.date_status_set:
71 status_date = _("Set on %s") % self.date_status_set73 status_date = _("Set on %s") % self.date_status_set
72 else:74 else:
@@ -77,12 +79,12 @@
77class ReadOnlyDateTimeWidget(Widget):79class ReadOnlyDateTimeWidget(Widget):
78 value = None80 value = None
7981
80 def render(self, name, value, attrs=None):82 def render(self, name, value, attrs=None, renderer=None):
81 return str(self.value)83 return str(self.value)
8284
8385
84class LPUsernameWidget(Widget):86class LPUsernameWidget(Widget):
85 account = None87 account = None
8688
87 def render(self, name, value, attrs=None):89 def render(self, name, value, attrs=None, renderer=None):
88 return mark_safe_lazy(account_to_lp_link(self.account))90 return mark_safe_lazy(account_to_lp_link(self.account))
8991
=== modified file 'src/ubuntu_sso_saml/tests/test_processors.py'
--- src/ubuntu_sso_saml/tests/test_processors.py 2018-04-16 16:32:22 +0000
+++ src/ubuntu_sso_saml/tests/test_processors.py 2018-05-30 16:21:15 +0000
@@ -10,9 +10,9 @@
10from StringIO import StringIO10from StringIO import StringIO
11from xml.dom import minidom11from xml.dom import minidom
1212
13from django.core.urlresolvers import reverse
14from django.test.client import Client13from django.test.client import Client
15from django.test.utils import override_settings14from django.test.utils import override_settings
15from django.urls import reverse
16from gargoyle.models import GLOBAL, Switch16from gargoyle.models import GLOBAL, Switch
17from gargoyle.testutils import switches17from gargoyle.testutils import switches
18from lxml import etree18from lxml import etree
1919
=== modified file 'src/ubuntu_sso_saml/tests/test_views.py'
--- src/ubuntu_sso_saml/tests/test_views.py 2018-04-04 14:49:47 +0000
+++ src/ubuntu_sso_saml/tests/test_views.py 2018-05-30 16:21:15 +0000
@@ -1,6 +1,6 @@
1import copy1import copy
22
3from django.core.urlresolvers import reverse3from django.urls import reverse
4from saml2idp import saml2idp_metadata4from saml2idp import saml2idp_metadata
55
6from identityprovider.tests.utils import SSOBaseTestCase6from identityprovider.tests.utils import SSOBaseTestCase
77
=== modified file 'src/ubuntu_sso_saml/views.py'
--- src/ubuntu_sso_saml/views.py 2018-04-04 14:49:47 +0000
+++ src/ubuntu_sso_saml/views.py 2018-05-30 16:21:15 +0000
@@ -3,8 +3,8 @@
3import logging3import logging
4from urlparse import urlparse, urlunparse4from urlparse import urlparse, urlunparse
55
6from django.core.urlresolvers import reverse
7from django.shortcuts import get_object_or_404, redirect, render6from django.shortcuts import get_object_or_404, redirect, render
7from django.urls import reverse
8from django.utils.datastructures import MultiValueDictKeyError8from django.utils.datastructures import MultiValueDictKeyError
9from django.views.decorators.csrf import csrf_exempt9from django.views.decorators.csrf import csrf_exempt
10from saml2idp import registry, saml2idp_metadata, xml_signing10from saml2idp import registry, saml2idp_metadata, xml_signing
1111
=== modified file 'src/webui/decorators.py'
--- src/webui/decorators.py 2018-05-25 20:41:26 +0000
+++ src/webui/decorators.py 2018-05-30 16:21:15 +0000
@@ -16,7 +16,6 @@
16)16)
17from django.contrib.auth.views import redirect_to_login17from django.contrib.auth.views import redirect_to_login
18from django.core.cache import cache18from django.core.cache import cache
19from django.core.urlresolvers import reverse
20from django.http import (19from django.http import (
21 Http404,20 Http404,
22 HttpResponseForbidden,21 HttpResponseForbidden,
@@ -24,6 +23,7 @@
24)23)
25from django.template.loader import render_to_string24from django.template.loader import render_to_string
26from django.template.response import TemplateResponse25from django.template.response import TemplateResponse
26from django.urls import reverse
27from django.utils.decorators import available_attrs27from django.utils.decorators import available_attrs
28from django.utils.http import (28from django.utils.http import (
29 urlencode,29 urlencode,
3030
=== modified file 'src/webui/tests/test_decorators.py'
--- src/webui/tests/test_decorators.py 2017-10-04 19:52:55 +0000
+++ src/webui/tests/test_decorators.py 2018-05-30 16:21:15 +0000
@@ -4,11 +4,11 @@
44
5from django.conf import settings5from django.conf import settings
6from django.contrib.auth.models import AnonymousUser6from django.contrib.auth.models import AnonymousUser
7from django.core.urlresolvers import reverse
8from django.http import (7from django.http import (
9 Http404,8 Http404,
10 HttpResponseRedirect,9 HttpResponseRedirect,
11)10)
11from django.urls import reverse
12from django.utils.timezone import now12from django.utils.timezone import now
13from gargoyle.testutils import switches13from gargoyle.testutils import switches
1414
@@ -354,7 +354,7 @@
354 self.assertEqual(self.calls, [])354 self.assertEqual(self.calls, [])
355 # user was logged out355 # user was logged out
356 self.assertIsInstance(self.request.user, AnonymousUser)356 self.assertIsInstance(self.request.user, AnonymousUser)
357 self.assertFalse(self.request.user.is_authenticated())357 self.assertFalse(self.request.user.is_authenticated)
358358
359359
360class SSOLoginRequiredNoEmailsTestCase(360class SSOLoginRequiredNoEmailsTestCase(
361361
=== modified file 'src/webui/tests/test_templates.py'
--- src/webui/tests/test_templates.py 2017-05-22 21:18:47 +0000
+++ src/webui/tests/test_templates.py 2018-05-30 16:21:15 +0000
@@ -1,7 +1,7 @@
1from __future__ import unicode_literals1from __future__ import unicode_literals
22
3from django.core.urlresolvers import reverse
4from django.template.loader import render_to_string3from django.template.loader import render_to_string
4from django.urls import reverse
5from mock import patch5from mock import patch
6from pyquery import PyQuery6from pyquery import PyQuery
77
88
=== modified file 'src/webui/tests/test_views_account.py'
--- src/webui/tests/test_views_account.py 2018-05-09 20:50:02 +0000
+++ src/webui/tests/test_views_account.py 2018-05-30 16:21:15 +0000
@@ -13,8 +13,9 @@
13from django.conf import settings13from django.conf import settings
14from django.contrib.auth.hashers import check_password14from django.contrib.auth.hashers import check_password
15from django.core import mail15from django.core import mail
16from django.core.urlresolvers import NoReverseMatch, reverse
17from django.test.utils import override_settings16from django.test.utils import override_settings
17from django.urls import reverse
18from django.urls.exceptions import NoReverseMatch
18from gargoyle.testutils import switches19from gargoyle.testutils import switches
19from pyquery import PyQuery20from pyquery import PyQuery
2021
2122
=== modified file 'src/webui/tests/test_views_account_ssh.py'
--- src/webui/tests/test_views_account_ssh.py 2018-02-08 15:12:52 +0000
+++ src/webui/tests/test_views_account_ssh.py 2018-05-30 16:21:15 +0000
@@ -3,7 +3,7 @@
33
4from __future__ import unicode_literals4from __future__ import unicode_literals
55
6from django.core.urlresolvers import reverse6from django.urls import reverse
7from gargoyle.testutils import switches7from gargoyle.testutils import switches
8from mock import call8from mock import call
99
1010
=== modified file 'src/webui/tests/test_views_auth_log.py'
--- src/webui/tests/test_views_auth_log.py 2018-02-09 20:56:16 +0000
+++ src/webui/tests/test_views_auth_log.py 2018-05-30 16:21:15 +0000
@@ -5,7 +5,7 @@
5from __future__ import unicode_literals5from __future__ import unicode_literals
66
7from django.conf import settings7from django.conf import settings
8from django.core.urlresolvers import reverse8from django.urls import reverse
9from django.utils.timezone import now, timedelta9from django.utils.timezone import now, timedelta
1010
11from identityprovider.models.const import AuthLogType11from identityprovider.models.const import AuthLogType
1212
=== modified file 'src/webui/tests/test_views_consumer.py'
--- src/webui/tests/test_views_consumer.py 2018-02-09 20:56:16 +0000
+++ src/webui/tests/test_views_consumer.py 2018-05-30 16:21:15 +0000
@@ -6,8 +6,8 @@
66
7from urllib import quote_plus7from urllib import quote_plus
88
9from django.core.urlresolvers import reverse
10from django.test.utils import override_settings9from django.test.utils import override_settings
10from django.urls import reverse
11from openid import fetchers11from openid import fetchers
12from openid.consumer import consumer12from openid.consumer import consumer
13from openid.consumer.discover import OPENID_2_0_TYPE, OpenIDServiceEndpoint13from openid.consumer.discover import OPENID_2_0_TYPE, OpenIDServiceEndpoint
1414
=== modified file 'src/webui/tests/test_views_devices.py'
--- src/webui/tests/test_views_devices.py 2018-03-16 13:30:26 +0000
+++ src/webui/tests/test_views_devices.py 2018-05-30 16:21:15 +0000
@@ -9,9 +9,9 @@
99
10import mock10import mock
11from django.conf import settings11from django.conf import settings
12from django.core.urlresolvers import reverse
13from django.db import transaction12from django.db import transaction
14from django.test.utils import override_settings13from django.test.utils import override_settings
14from django.urls import reverse
15from django.utils.timezone import now15from django.utils.timezone import now
16from gargoyle.testutils import switches16from gargoyle.testutils import switches
17from oath import hotp, totp17from oath import hotp, totp
1818
=== modified file 'src/webui/tests/test_views_i18n.py'
--- src/webui/tests/test_views_i18n.py 2018-02-09 20:56:16 +0000
+++ src/webui/tests/test_views_i18n.py 2018-05-30 16:21:15 +0000
@@ -1,6 +1,6 @@
1from __future__ import unicode_literals1from __future__ import unicode_literals
22
3from django.core.urlresolvers import reverse3from django.urls import reverse
44
5from identityprovider.models.account import Account5from identityprovider.models.account import Account
6from identityprovider.tests import DEFAULT_USER_PASSWORD6from identityprovider.tests import DEFAULT_USER_PASSWORD
77
=== modified file 'src/webui/tests/test_views_registration.py'
--- src/webui/tests/test_views_registration.py 2018-05-25 22:00:09 +0000
+++ src/webui/tests/test_views_registration.py 2018-05-30 16:21:15 +0000
@@ -9,8 +9,8 @@
99
10from django.conf import settings10from django.conf import settings
11from django.contrib.auth.models import AnonymousUser11from django.contrib.auth.models import AnonymousUser
12from django.core.urlresolvers import reverse
13from django.test.utils import override_settings12from django.test.utils import override_settings
13from django.urls import reverse
1414
15from gargoyle.testutils import switches15from gargoyle.testutils import switches
16from mock import Mock, call16from mock import Mock, call
1717
=== modified file 'src/webui/tests/test_views_ui.py'
--- src/webui/tests/test_views_ui.py 2018-02-20 17:14:51 +0000
+++ src/webui/tests/test_views_ui.py 2018-05-30 16:21:15 +0000
@@ -25,9 +25,9 @@
25from django.core import mail25from django.core import mail
26from django.core.cache import cache26from django.core.cache import cache
27from django.core.exceptions import ValidationError27from django.core.exceptions import ValidationError
28from django.core.urlresolvers import reverse
29from django.http import QueryDict28from django.http import QueryDict
30from django.test.utils import override_settings29from django.test.utils import override_settings
30from django.urls import reverse
31from django.utils.html import escape31from django.utils.html import escape
32from gargoyle import gargoyle32from gargoyle import gargoyle
33from gargoyle.testutils import switches33from gargoyle.testutils import switches
@@ -1964,7 +1964,7 @@
1964 account = Account.objects.get(id=self.account.id)1964 account = Account.objects.get(id=self.account.id)
19651965
1966 self.assertTemplateUsed(response, 'account/suspended.html')1966 self.assertTemplateUsed(response, 'account/suspended.html')
1967 self.assertFalse(response.context['user'].is_authenticated())1967 self.assertFalse(response.context['user'].is_authenticated)
1968 self.assertEqual(account.status, AccountStatus.SUSPENDED)1968 self.assertEqual(account.status, AccountStatus.SUSPENDED)
1969 # since the account is NOT on the expected team, no email is sent1969 # since the account is NOT on the expected team, no email is sent
1970 self.assert_no_emails_sent()1970 self.assert_no_emails_sent()
@@ -1979,7 +1979,7 @@
1979 account = Account.objects.get(id=self.account.id)1979 account = Account.objects.get(id=self.account.id)
19801980
1981 self.assertTemplateUsed(response, 'account/suspended.html')1981 self.assertTemplateUsed(response, 'account/suspended.html')
1982 self.assertFalse(response.context['user'].is_authenticated())1982 self.assertFalse(response.context['user'].is_authenticated)
1983 self.assertEqual(account.status, AccountStatus.SUSPENDED)1983 self.assertEqual(account.status, AccountStatus.SUSPENDED)
1984 # since the account is on the expected team, a notification is sent1984 # since the account is on the expected team, a notification is sent
1985 self.assert_account_suspended_warning_sent(account)1985 self.assert_account_suspended_warning_sent(account)
19861986
=== modified file 'src/webui/views/account.py'
--- src/webui/views/account.py 2018-05-25 20:41:26 +0000
+++ src/webui/views/account.py 2018-05-30 16:21:15 +0000
@@ -10,11 +10,11 @@
1010
11from django.conf import settings11from django.conf import settings
12from django.contrib import auth, messages12from django.contrib import auth, messages
13from django.core.urlresolvers import reverse
14from django.http import HttpResponseRedirect13from django.http import HttpResponseRedirect
15from django.shortcuts import get_object_or_404, render14from django.shortcuts import get_object_or_404, render
16from django.template.loader import render_to_string15from django.template.loader import render_to_string
17from django.template.response import TemplateResponse16from django.template.response import TemplateResponse
17from django.urls import reverse
18from django.views.decorators.vary import vary_on_headers18from django.views.decorators.vary import vary_on_headers
19from gargoyle import gargoyle19from gargoyle import gargoyle
20from gargoyle.decorators import switch_is_active20from gargoyle.decorators import switch_is_active
2121
=== modified file 'src/webui/views/consumer.py'
--- src/webui/views/consumer.py 2018-02-09 20:56:16 +0000
+++ src/webui/views/consumer.py 2018-05-30 16:21:15 +0000
@@ -13,9 +13,9 @@
1313
14from django.conf import settings14from django.conf import settings
15from django.contrib import messages15from django.contrib import messages
16from django.core.urlresolvers import reverse
17from django.http import HttpResponseRedirect16from django.http import HttpResponseRedirect
18from django.shortcuts import render17from django.shortcuts import render
18from django.urls import reverse
19from django.utils.translation import ugettext_lazy as _19from django.utils.translation import ugettext_lazy as _
20from django.views.decorators.csrf import csrf_exempt20from django.views.decorators.csrf import csrf_exempt
21from django_openid_auth.store import DjangoOpenIDStore21from django_openid_auth.store import DjangoOpenIDStore
2222
=== modified file 'src/webui/views/devices.py'
--- src/webui/views/devices.py 2018-02-09 20:56:16 +0000
+++ src/webui/views/devices.py 2018-05-30 16:21:15 +0000
@@ -10,10 +10,10 @@
10from django.conf import settings10from django.conf import settings
11from django.contrib import messages11from django.contrib import messages
12from django.contrib.auth.views import redirect_to_login12from django.contrib.auth.views import redirect_to_login
13from django.core.urlresolvers import reverse
14from django.http import HttpResponseRedirect13from django.http import HttpResponseRedirect
15from django.shortcuts import get_object_or_404, render14from django.shortcuts import get_object_or_404, render
16from django.template.response import TemplateResponse15from django.template.response import TemplateResponse
16from django.urls import reverse
17from django.utils.translation import ugettext_lazy as _17from django.utils.translation import ugettext_lazy as _
18from django.views.generic import View18from django.views.generic import View
19from gargoyle import gargoyle19from gargoyle import gargoyle
2020
=== modified file 'src/webui/views/errors.py'
--- src/webui/views/errors.py 2018-02-14 14:05:59 +0000
+++ src/webui/views/errors.py 2018-05-30 16:21:15 +0000
@@ -12,7 +12,7 @@
12 self.status_code = status12 self.status_code = status
13 self.errormsg = errormsg13 self.errormsg = errormsg
1414
15 def __call__(self, request):15 def __call__(self, request, exception=None):
16 oopsid = request.environ.get('oops.report', {}).get('id', None)16 oopsid = request.environ.get('oops.report', {}).get('id', None)
17 atts = {17 atts = {
18 'request': request,18 'request': request,
1919
=== modified file 'src/webui/views/i18n.py'
--- src/webui/views/i18n.py 2018-02-09 20:56:16 +0000
+++ src/webui/views/i18n.py 2018-05-30 16:21:15 +0000
@@ -34,7 +34,7 @@
34 if lang not in settings.SUPPORTED_LANGUAGES:34 if lang not in settings.SUPPORTED_LANGUAGES:
35 raise Http404('Unsupported language')35 raise Http404('Unsupported language')
3636
37 if request.user.is_authenticated():37 if request.user.is_authenticated:
38 account = request.user38 account = request.user
39 account.preferredlanguage = lang39 account.preferredlanguage = lang
40 account.save()40 account.save()
4141
=== modified file 'src/webui/views/registration.py'
--- src/webui/views/registration.py 2018-02-15 11:27:21 +0000
+++ src/webui/views/registration.py 2018-05-30 16:21:15 +0000
@@ -7,7 +7,6 @@
7from django.conf import settings7from django.conf import settings
8from django.contrib import auth, messages8from django.contrib import auth, messages
9from django.contrib.auth.decorators import login_required9from django.contrib.auth.decorators import login_required
10from django.core.urlresolvers import reverse
11from django.http import (10from django.http import (
12 HttpResponseNotAllowed,11 HttpResponseNotAllowed,
13 HttpResponseRedirect,12 HttpResponseRedirect,
@@ -15,6 +14,7 @@
15)14)
16from django.template.loader import render_to_string15from django.template.loader import render_to_string
17from django.template.response import TemplateResponse16from django.template.response import TemplateResponse
17from django.urls import reverse
18from django.utils.decorators import method_decorator18from django.utils.decorators import method_decorator
19from django.utils.translation import ugettext_lazy as _19from django.utils.translation import ugettext_lazy as _
20from django.views.decorators.http import require_http_methods20from django.views.decorators.http import require_http_methods
2121
=== modified file 'src/webui/views/ui.py'
--- src/webui/views/ui.py 2018-05-10 20:20:47 +0000
+++ src/webui/views/ui.py 2018-05-30 16:21:15 +0000
@@ -11,7 +11,6 @@
11from django.conf import settings11from django.conf import settings
12from django.contrib import auth, messages12from django.contrib import auth, messages
13from django.contrib.auth.decorators import login_required13from django.contrib.auth.decorators import login_required
14from django.core.urlresolvers import reverse
15from django.http import (14from django.http import (
16 Http404,15 Http404,
17 HttpResponse,16 HttpResponse,
@@ -25,6 +24,7 @@
25)24)
26from django.template.loader import render_to_string25from django.template.loader import render_to_string
27from django.template.response import TemplateResponse26from django.template.response import TemplateResponse
27from django.urls import reverse
28from django.utils.decorators import method_decorator28from django.utils.decorators import method_decorator
29from django.utils.http import urlquote29from django.utils.http import urlquote
30from django.utils.translation import ugettext_lazy as _30from django.utils.translation import ugettext_lazy as _