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
1=== modified file 'django_project/settings_base.py'
2--- django_project/settings_base.py 2015-06-30 21:39:29 +0000
3+++ django_project/settings_base.py 2015-07-20 19:43:14 +0000
4@@ -42,6 +42,8 @@
5 APP_SERVERS = []
6 AUTHENTICATION_BACKENDS = [
7 'identityprovider.auth.LaunchpadBackend',
8+ # Once we debug LP: # 1476255, we should remove the ModelBackend
9+ # from this list
10 'django.contrib.auth.backends.ModelBackend',
11 'django_openid_auth.auth.OpenIDBackend',
12 ]
13
14=== modified file 'src/identityprovider/login.py'
15--- src/identityprovider/login.py 2015-07-01 15:16:55 +0000
16+++ src/identityprovider/login.py 2015-07-20 19:43:14 +0000
17@@ -1,5 +1,8 @@
18 # Copyright 2010-2013 Canonical Ltd. This software is licensed under the
19 # GNU Affero General Public License version 3 (see the file LICENSE).
20+
21+import logging
22+
23 from django.contrib import auth
24 from django.template.loader import render_to_string
25 from django.utils.translation import ugettext_lazy as _
26@@ -12,6 +15,7 @@
27 from identityprovider.validators import ValidationError, get_password_validator
28
29 LOGIN_INCORRECT = _('Incorrect email/password combination')
30+logger = logging.getLogger(__name__)
31
32
33 class AuthenticationError(Exception):
34@@ -71,6 +75,16 @@
35
36 raise AuthenticationError(LOGIN_INCORRECT)
37
38+ # Adding debug information for LP: #1476255
39+ # AttributeError: 'User' object has no attribute 'person_in_team'
40+ if not isinstance(account, Account):
41+ logger.warning(
42+ 'authenticate_user: call to auth.authenticate returned a non '
43+ 'Account instance (%s, id: %r, backend: %r) for email %r, '
44+ 'and rpconfig %r.',
45+ account.__class__.__name__, getattr(account, 'id', None),
46+ getattr(account, 'backend', None), email, rpconfig)
47+
48 validate_policy = get_password_validator(account=account)
49 try:
50 validate_policy(password)
51
52=== modified file 'src/identityprovider/tests/test_admin.py'
53--- src/identityprovider/tests/test_admin.py 2015-06-24 23:20:24 +0000
54+++ src/identityprovider/tests/test_admin.py 2015-07-20 19:43:14 +0000
55@@ -139,13 +139,22 @@
56 'devices-INITIAL_FORMS': '0',
57 }
58 parameters.update(kwargs)
59- r = self.client.post(change_view, parameters)
60+ response = self.client.post(change_view, parameters)
61
62 if success:
63+ status_code = response.status_code
64+ # If view returns with 200 on POST, it means the form has errors.
65+ if status_code == 200:
66+ self.assertEqual(response.context['errors'], [])
67+
68 # Any non-error status code would be fine here, but right now
69 # it redirects with a 302.
70- self.assertEqual(r.status_code, 302)
71- return r
72+ self.assertEqual(
73+ status_code, 302,
74+ 'Response did not redirect as expected, response is: %s' %
75+ response)
76+
77+ return response
78
79 def test_account_change(self):
80 new_email = 'mark2@example.com'
81
82=== modified file 'src/identityprovider/tests/test_models_account.py'
83--- src/identityprovider/tests/test_models_account.py 2015-07-01 19:20:49 +0000
84+++ src/identityprovider/tests/test_models_account.py 2015-07-20 19:43:14 +0000
85@@ -1251,3 +1251,16 @@
86
87 self.assertIn('there was a security breach', str(ctx.exception))
88 self.assertEqual(ctx.exception.account, self.account)
89+
90+ def test_non_account_instance(self):
91+ mock_logger = self._apply_patch('identityprovider.login.logger')
92+ user = User.objects.create_user(username='test', password='12345678')
93+
94+ with self.assertRaises(AttributeError):
95+ authenticate_user(user.username, '12345678')
96+
97+ mock_logger.warning.assert_called_once_with(
98+ 'authenticate_user: call to auth.authenticate returned a non '
99+ 'Account instance (%s, id: %r, backend: %r) for email %r, and '
100+ 'rpconfig %r.', 'User', user.id,
101+ 'django.contrib.auth.backends.ModelBackend', 'test', None)