Merge lp:~mhall119/summit/auto-set-user-openid into lp:summit

Proposed by Michael Hall
Status: Merged
Approved by: James Westby
Approved revision: 202
Merged at revision: 202
Proposed branch: lp:~mhall119/summit/auto-set-user-openid
Merge into: lp:summit
Diff against target: 51 lines (+19/-0)
2 files modified
summit/schedule/models/summitmodel.py (+3/-0)
summit/schedule/tests.py (+16/-0)
To merge this branch: bzr merge lp:~mhall119/summit/auto-set-user-openid
Reviewer Review Type Date Requested Status
James Westby (community) Approve
Review via email: mp+80070@code.launchpad.net

Commit message

Set user openid when creating a new user from lpupdate

Description of the change

Set user openid when creating a new user from lpupdate.

If we create a user from launchpad without setting their openid, then when they try to log in they won't be able to use their launchpad username, since it will already exist but without their openid association. Previously this would cause them to get {launchpad_username}2 as their username, but with the introduction of the OPENID_STRICT_USERNAMES policy it would cause their login to fail.

To post a comment you must log in.
Revision history for this message
James Westby (james-w) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'summit/schedule/models/summitmodel.py'
2--- summit/schedule/models/summitmodel.py 2011-09-30 20:08:35 +0000
3+++ summit/schedule/models/summitmodel.py 2011-10-21 13:46:18 +0000
4@@ -33,6 +33,8 @@
5 from django.contrib.auth.models import User
6
7 from summit.schedule.fields import NameField
8+from summit.schedule import launchpad
9+
10
11 __all__ = (
12 'Summit',
13@@ -259,6 +261,7 @@
14 user = User.objects.get(username__exact=username[:30])
15 except ObjectDoesNotExist:
16 user = User.objects.create_user(username[:30], '', password=None)
17+ launchpad.set_user_openid(user)
18
19 # Create with any start/end time since we overwrite shortly
20 attendee = self.attendee_set.create(user=user,
21
22=== modified file 'summit/schedule/tests.py'
23--- summit/schedule/tests.py 2011-10-20 12:30:40 +0000
24+++ summit/schedule/tests.py 2011-10-21 13:46:18 +0000
25@@ -34,6 +34,7 @@
26
27 from summit.schedule.models import *
28 from summit.schedule.render import Schedule
29+from summit.schedule import launchpad
30
31 # Monkey-patch our NameField into the types of fields that the factory
32 # understands. This is simpler than trying to subclass the Mommy
33@@ -1665,3 +1666,18 @@
34 auto=False)
35 summit.reschedule()
36 self.assertEqual(1, slot.agenda_set.all().count())
37+
38+ def test_update_from_launchpad_adds_attendees(self):
39+ def mock_set_openid(user, force=False):
40+ self.assertEquals(user.username, 'testuser')
41+ mock_set_openid.called = True
42+ return True
43+ mock_set_openid.called = False
44+ launchpad.set_user_openid = mock_set_openid
45+
46+ summit = factory.make_one(Summit)
47+ attendee_node = LaunchpadExportNode(name='testuser')
48+ summit.update_attendee_from_launchpad(attendee_node)
49+
50+ self.assertEqual(1, summit.attendee_set.filter(user__username__exact="testuser").count())
51+ self.assertTrue(mock_set_openid.called)

Subscribers

People subscribed via source and target branches