Merge lp:~nataliabidart/canonical-identity-provider/user-person-in-team into lp:canonical-identity-provider/release

Proposed by Natalia Bidart
Status: Merged
Approved by: Natalia Bidart
Approved revision: no longer in the source branch.
Merged at revision: 1303
Proposed branch: lp:~nataliabidart/canonical-identity-provider/user-person-in-team
Merge into: lp:canonical-identity-provider/release
Diff against target: 101 lines (+41/-3)
4 files modified
django_project/settings_base.py (+2/-0)
src/identityprovider/login.py (+14/-0)
src/identityprovider/tests/test_admin.py (+12/-3)
src/identityprovider/tests/test_models_account.py (+13/-0)
To merge this branch: bzr merge lp:~nataliabidart/canonical-identity-provider/user-person-in-team
Reviewer Review Type Date Requested Status
Daniel Manrique (community) Approve
Matt Goodall (community) Approve
Review via email: mp+265286@code.launchpad.net

Commit message

- Added log messages to try to pin point why authenticate backends are returning a user instead of an account.

To post a comment you must log in.
Revision history for this message
Matt Goodall (matt-goodall) wrote :

lgtm

review: Approve
Revision history for this message
Daniel Manrique (roadmr) wrote :

Looks OK to me, I'd say to put a FIXME or TODO as part of the "remove the ModelBackend later" comment so it's easier to find, but I don't think it's a big deal since this should be resolved before we forget about that :)

review: Approve
Revision history for this message
Ubuntu One Auto Pilot (otto-pilot) wrote :
Download full text (26.9 KiB)

The attempt to merge lp:~nataliabidart/canonical-identity-provider/user-person-in-team into lp:canonical-identity-provider failed. Below is the output from the failed tests.

Bootstrapping...
rm -rf /mnt/tarmac/cache/canonical-identity-provider/merges/trunk/env
rm -rf branches/wheels
rm -rf branches/*
rm -rf staticfiles
rm -f lib/versioninfo.py
find -name '*.pyc' -delete
find -name '*.~*' -delete
Not deleting /mnt/tarmac/cache/canonical-identity-provider/merges/trunk/env/bin
New python executable in /mnt/tarmac/cache/canonical-identity-provider/merges/trunk/env/bin/python
Installing setuptools, pip...done.
/usr/lib/config-manager/cm.py update config-manager.txt
touch branches/last_build
[ -d branches/wheels ] && (cd branches/wheels && bzr pull) || (bzr branch lp:~ubuntuone-pqm-team/canonical-identity-provider/dependencies branches/wheels)
bzr version-info --format=python > lib/versioninfo.py
/mnt/tarmac/cache/canonical-identity-provider/merges/trunk/env/bin/pip install --verbose --find-links=branches/wheels --no-index -r requirements.txt
Ignoring indexes: https://pypi.python.org/simple/
Downloading/unpacking bson==0.3.3 (from -r requirements.txt (line 1))
  Local files found: /mnt/tarmac/cache/canonical-identity-provider/merges/trunk/branches/wheels/bson-0.3.3-py2-none-any.whl
Downloading/unpacking convoy==0.4.1 (from -r requirements.txt (line 2))
  Local files found: /mnt/tarmac/cache/canonical-identity-provider/merges/trunk/branches/wheels/convoy-0.4.1-py2-none-any.whl, /mnt/tarmac/cache/canonical-identity-provider/merges/trunk/branches/wheels/convoy-0.2.2-py2-none-any.whl
  Ignoring link file:///mnt/tarmac/cache/canonical-identity-provider/merges/trunk/branches/wheels/convoy-0.2.2-py2-none-any.whl, version 0.2.2 doesn't match ==0.4.1
Downloading/unpacking dj-static==0.0.6.dev1 (from -r requirements.txt (line 3))
  Local files found: /mnt/tarmac/cache/canonical-identity-provider/merges/trunk/branches/wheels/dj_static-0.0.6.dev1-py2-none-any.whl
Downloading/unpacking django==1.7.9 (from -r requirements.txt (line 4))
  Local files found: /mnt/tarmac/cache/canonical-identity-provider/merges/trunk/branches/wheels/Django-1.8.3-py2.py3-none-any.whl, /mnt/tarmac/cache/canonical-identity-provider/merges/trunk/branches/wheels/Django-1.7.9-py2.py3-none-any.whl, /mnt/tarmac/cache/canonical-identity-provider/merges/trunk/branches/wheels/Django-1.7.8-py2.py3-none-any.whl
  Ignoring link file:///mnt/tarmac/cache/canonical-identity-provider/merges/trunk/branches/wheels/Django-1.8.3-py2.py3-none-any.whl, version 1.8.3 doesn't match ==1.7.9
  Ignoring link file:///mnt/tarmac/cache/canonical-identity-provider/merges/trunk/branches/wheels/Django-1.7.8-py2.py3-none-any.whl, version 1.7.8 doesn't match ==1.7.9
Downloading/unpacking django-honeypot==0.4.0 (from -r requirements.txt (line 5))
  Local files found: /mnt/tarmac/cache/canonical-identity-provider/merges/trunk/branches/wheels/django_honeypot-0.4.0-py2-none-any.whl
Downloading/unpacking django-jsonfield==0.9.13 (from -r requirements.txt (line 6))
  Local files found: /mnt/tarmac/cache/canonical-identity-provider/merges/trunk/branches/wheels/django_jsonfield-0.9.13-py2-none-any.whl
Downloading/unpacking d...

Revision history for this message
Ubuntu One Auto Pilot (otto-pilot) wrote :
Download full text (26.9 KiB)

The attempt to merge lp:~nataliabidart/canonical-identity-provider/user-person-in-team into lp:canonical-identity-provider failed. Below is the output from the failed tests.

Bootstrapping...
rm -rf /mnt/tarmac/cache/canonical-identity-provider/merges/trunk/env
rm -rf branches/wheels
rm -rf branches/*
rm -rf staticfiles
rm -f lib/versioninfo.py
find -name '*.pyc' -delete
find -name '*.~*' -delete
Not deleting /mnt/tarmac/cache/canonical-identity-provider/merges/trunk/env/bin
New python executable in /mnt/tarmac/cache/canonical-identity-provider/merges/trunk/env/bin/python
Installing setuptools, pip...done.
/usr/lib/config-manager/cm.py update config-manager.txt
touch branches/last_build
[ -d branches/wheels ] && (cd branches/wheels && bzr pull) || (bzr branch lp:~ubuntuone-pqm-team/canonical-identity-provider/dependencies branches/wheels)
bzr version-info --format=python > lib/versioninfo.py
/mnt/tarmac/cache/canonical-identity-provider/merges/trunk/env/bin/pip install --verbose --find-links=branches/wheels --no-index -r requirements.txt
Ignoring indexes: https://pypi.python.org/simple/
Downloading/unpacking bson==0.3.3 (from -r requirements.txt (line 1))
  Local files found: /mnt/tarmac/cache/canonical-identity-provider/merges/trunk/branches/wheels/bson-0.3.3-py2-none-any.whl
Downloading/unpacking convoy==0.4.1 (from -r requirements.txt (line 2))
  Local files found: /mnt/tarmac/cache/canonical-identity-provider/merges/trunk/branches/wheels/convoy-0.4.1-py2-none-any.whl, /mnt/tarmac/cache/canonical-identity-provider/merges/trunk/branches/wheels/convoy-0.2.2-py2-none-any.whl
  Ignoring link file:///mnt/tarmac/cache/canonical-identity-provider/merges/trunk/branches/wheels/convoy-0.2.2-py2-none-any.whl, version 0.2.2 doesn't match ==0.4.1
Downloading/unpacking dj-static==0.0.6.dev1 (from -r requirements.txt (line 3))
  Local files found: /mnt/tarmac/cache/canonical-identity-provider/merges/trunk/branches/wheels/dj_static-0.0.6.dev1-py2-none-any.whl
Downloading/unpacking django==1.7.9 (from -r requirements.txt (line 4))
  Local files found: /mnt/tarmac/cache/canonical-identity-provider/merges/trunk/branches/wheels/Django-1.8.3-py2.py3-none-any.whl, /mnt/tarmac/cache/canonical-identity-provider/merges/trunk/branches/wheels/Django-1.7.9-py2.py3-none-any.whl, /mnt/tarmac/cache/canonical-identity-provider/merges/trunk/branches/wheels/Django-1.7.8-py2.py3-none-any.whl
  Ignoring link file:///mnt/tarmac/cache/canonical-identity-provider/merges/trunk/branches/wheels/Django-1.8.3-py2.py3-none-any.whl, version 1.8.3 doesn't match ==1.7.9
  Ignoring link file:///mnt/tarmac/cache/canonical-identity-provider/merges/trunk/branches/wheels/Django-1.7.8-py2.py3-none-any.whl, version 1.7.8 doesn't match ==1.7.9
Downloading/unpacking django-honeypot==0.4.0 (from -r requirements.txt (line 5))
  Local files found: /mnt/tarmac/cache/canonical-identity-provider/merges/trunk/branches/wheels/django_honeypot-0.4.0-py2-none-any.whl
Downloading/unpacking django-jsonfield==0.9.13 (from -r requirements.txt (line 6))
  Local files found: /mnt/tarmac/cache/canonical-identity-provider/merges/trunk/branches/wheels/django_jsonfield-0.9.13-py2-none-any.whl
Downloading/unpacking d...

Revision history for this message
Ubuntu One Auto Pilot (otto-pilot) wrote :
Download full text (27.1 KiB)

The attempt to merge lp:~nataliabidart/canonical-identity-provider/user-person-in-team into lp:canonical-identity-provider failed. Below is the output from the failed tests.

Bootstrapping...
rm -rf /mnt/tarmac/cache/canonical-identity-provider/merges/trunk/env
rm -rf branches/wheels
rm -rf branches/*
rm -rf staticfiles
rm -f lib/versioninfo.py
find -name '*.pyc' -delete
find -name '*.~*' -delete
Not deleting /mnt/tarmac/cache/canonical-identity-provider/merges/trunk/env/bin
New python executable in /mnt/tarmac/cache/canonical-identity-provider/merges/trunk/env/bin/python
Installing setuptools, pip...done.
/usr/lib/config-manager/cm.py update config-manager.txt
touch branches/last_build
[ -d branches/wheels ] && (cd branches/wheels && bzr pull) || (bzr branch lp:~ubuntuone-pqm-team/canonical-identity-provider/dependencies branches/wheels)
bzr version-info --format=python > lib/versioninfo.py
/mnt/tarmac/cache/canonical-identity-provider/merges/trunk/env/bin/pip install --verbose --find-links=branches/wheels --no-index -r requirements.txt
Ignoring indexes: https://pypi.python.org/simple/
Downloading/unpacking bson==0.3.3 (from -r requirements.txt (line 1))
  Local files found: /mnt/tarmac/cache/canonical-identity-provider/merges/trunk/branches/wheels/bson-0.3.3-py2-none-any.whl
Downloading/unpacking convoy==0.4.1 (from -r requirements.txt (line 2))
  Local files found: /mnt/tarmac/cache/canonical-identity-provider/merges/trunk/branches/wheels/convoy-0.4.1-py2-none-any.whl, /mnt/tarmac/cache/canonical-identity-provider/merges/trunk/branches/wheels/convoy-0.2.2-py2-none-any.whl
  Ignoring link file:///mnt/tarmac/cache/canonical-identity-provider/merges/trunk/branches/wheels/convoy-0.2.2-py2-none-any.whl, version 0.2.2 doesn't match ==0.4.1
Downloading/unpacking dj-static==0.0.6.dev1 (from -r requirements.txt (line 3))
  Local files found: /mnt/tarmac/cache/canonical-identity-provider/merges/trunk/branches/wheels/dj_static-0.0.6.dev1-py2-none-any.whl
Downloading/unpacking django==1.7.9 (from -r requirements.txt (line 4))
  Local files found: /mnt/tarmac/cache/canonical-identity-provider/merges/trunk/branches/wheels/Django-1.8.3-py2.py3-none-any.whl, /mnt/tarmac/cache/canonical-identity-provider/merges/trunk/branches/wheels/Django-1.7.9-py2.py3-none-any.whl, /mnt/tarmac/cache/canonical-identity-provider/merges/trunk/branches/wheels/Django-1.7.8-py2.py3-none-any.whl
  Ignoring link file:///mnt/tarmac/cache/canonical-identity-provider/merges/trunk/branches/wheels/Django-1.8.3-py2.py3-none-any.whl, version 1.8.3 doesn't match ==1.7.9
  Ignoring link file:///mnt/tarmac/cache/canonical-identity-provider/merges/trunk/branches/wheels/Django-1.7.8-py2.py3-none-any.whl, version 1.7.8 doesn't match ==1.7.9
Downloading/unpacking django-honeypot==0.4.0 (from -r requirements.txt (line 5))
  Local files found: /mnt/tarmac/cache/canonical-identity-provider/merges/trunk/branches/wheels/django_honeypot-0.4.0-py2-none-any.whl
Downloading/unpacking django-jsonfield==0.9.13 (from -r requirements.txt (line 6))
  Local files found: /mnt/tarmac/cache/canonical-identity-provider/merges/trunk/branches/wheels/django_jsonfield-0.9.13-py2-none-any.whl
Downloading/unpacking d...

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'django_project/settings_base.py'
--- django_project/settings_base.py 2015-06-30 21:39:29 +0000
+++ django_project/settings_base.py 2015-07-20 19:43:14 +0000
@@ -42,6 +42,8 @@
42APP_SERVERS = []42APP_SERVERS = []
43AUTHENTICATION_BACKENDS = [43AUTHENTICATION_BACKENDS = [
44 'identityprovider.auth.LaunchpadBackend',44 'identityprovider.auth.LaunchpadBackend',
45 # Once we debug LP: # 1476255, we should remove the ModelBackend
46 # from this list
45 'django.contrib.auth.backends.ModelBackend',47 'django.contrib.auth.backends.ModelBackend',
46 'django_openid_auth.auth.OpenIDBackend',48 'django_openid_auth.auth.OpenIDBackend',
47]49]
4850
=== modified file 'src/identityprovider/login.py'
--- src/identityprovider/login.py 2015-07-01 15:16:55 +0000
+++ src/identityprovider/login.py 2015-07-20 19:43:14 +0000
@@ -1,5 +1,8 @@
1# Copyright 2010-2013 Canonical Ltd. This software is licensed under the1# Copyright 2010-2013 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).
3
4import logging
5
3from django.contrib import auth6from django.contrib import auth
4from django.template.loader import render_to_string7from django.template.loader import render_to_string
5from django.utils.translation import ugettext_lazy as _8from django.utils.translation import ugettext_lazy as _
@@ -12,6 +15,7 @@
12from identityprovider.validators import ValidationError, get_password_validator15from identityprovider.validators import ValidationError, get_password_validator
1316
14LOGIN_INCORRECT = _('Incorrect email/password combination')17LOGIN_INCORRECT = _('Incorrect email/password combination')
18logger = logging.getLogger(__name__)
1519
1620
17class AuthenticationError(Exception):21class AuthenticationError(Exception):
@@ -71,6 +75,16 @@
7175
72 raise AuthenticationError(LOGIN_INCORRECT)76 raise AuthenticationError(LOGIN_INCORRECT)
7377
78 # Adding debug information for LP: #1476255
79 # AttributeError: 'User' object has no attribute 'person_in_team'
80 if not isinstance(account, Account):
81 logger.warning(
82 'authenticate_user: call to auth.authenticate returned a non '
83 'Account instance (%s, id: %r, backend: %r) for email %r, '
84 'and rpconfig %r.',
85 account.__class__.__name__, getattr(account, 'id', None),
86 getattr(account, 'backend', None), email, rpconfig)
87
74 validate_policy = get_password_validator(account=account)88 validate_policy = get_password_validator(account=account)
75 try:89 try:
76 validate_policy(password)90 validate_policy(password)
7791
=== modified file 'src/identityprovider/tests/test_admin.py'
--- src/identityprovider/tests/test_admin.py 2015-06-24 23:20:24 +0000
+++ src/identityprovider/tests/test_admin.py 2015-07-20 19:43:14 +0000
@@ -139,13 +139,22 @@
139 'devices-INITIAL_FORMS': '0',139 'devices-INITIAL_FORMS': '0',
140 }140 }
141 parameters.update(kwargs)141 parameters.update(kwargs)
142 r = self.client.post(change_view, parameters)142 response = self.client.post(change_view, parameters)
143143
144 if success:144 if success:
145 status_code = response.status_code
146 # If view returns with 200 on POST, it means the form has errors.
147 if status_code == 200:
148 self.assertEqual(response.context['errors'], [])
149
145 # Any non-error status code would be fine here, but right now150 # Any non-error status code would be fine here, but right now
146 # it redirects with a 302.151 # it redirects with a 302.
147 self.assertEqual(r.status_code, 302)152 self.assertEqual(
148 return r153 status_code, 302,
154 'Response did not redirect as expected, response is: %s' %
155 response)
156
157 return response
149158
150 def test_account_change(self):159 def test_account_change(self):
151 new_email = 'mark2@example.com'160 new_email = 'mark2@example.com'
152161
=== modified file 'src/identityprovider/tests/test_models_account.py'
--- src/identityprovider/tests/test_models_account.py 2015-07-01 19:20:49 +0000
+++ src/identityprovider/tests/test_models_account.py 2015-07-20 19:43:14 +0000
@@ -1251,3 +1251,16 @@
12511251
1252 self.assertIn('there was a security breach', str(ctx.exception))1252 self.assertIn('there was a security breach', str(ctx.exception))
1253 self.assertEqual(ctx.exception.account, self.account)1253 self.assertEqual(ctx.exception.account, self.account)
1254
1255 def test_non_account_instance(self):
1256 mock_logger = self._apply_patch('identityprovider.login.logger')
1257 user = User.objects.create_user(username='test', password='12345678')
1258
1259 with self.assertRaises(AttributeError):
1260 authenticate_user(user.username, '12345678')
1261
1262 mock_logger.warning.assert_called_once_with(
1263 'authenticate_user: call to auth.authenticate returned a non '
1264 'Account instance (%s, id: %r, backend: %r) for email %r, and '
1265 'rpconfig %r.', 'User', user.id,
1266 'django.contrib.auth.backends.ModelBackend', 'test', None)