Merge lp:~nataliabidart/ubuntu-sso-client/displayname-stable into lp:ubuntu-sso-client/stable-1-0

Proposed by Natalia Bidart
Status: Merged
Approved by: Natalia Bidart
Approved revision: 645
Merged at revision: 644
Proposed branch: lp:~nataliabidart/ubuntu-sso-client/displayname-stable
Merge into: lp:ubuntu-sso-client/stable-1-0
Diff against target: 297 lines (+71/-62)
5 files modified
data/ui.glade (+40/-32)
ubuntu_sso/gui.py (+8/-10)
ubuntu_sso/main.py (+10/-7)
ubuntu_sso/tests/test_gui.py (+1/-6)
ubuntu_sso/tests/test_main.py (+12/-7)
To merge this branch: bzr merge lp:~nataliabidart/ubuntu-sso-client/displayname-stable
Reviewer Review Type Date Requested Status
Manuel de la Peña (community) Approve
Eric Casteleijn (community) Approve
Review via email: mp+54705@code.launchpad.net

Commit message

- Register now uses the 'displayname' field to pass it on to SSO as display name (LP: #709494).

Description of the change

To properly test please use the SRU instructions in the attached bug report. Thanks!

To post a comment you must log in.
Revision history for this message
Eric Casteleijn (thisfred) wrote :

Confirmed that I can't leave name blank, and the full name shows up in login.ubuntu.com, after using this branch to register from a maverick machine.

review: Approve
Revision history for this message
Manuel de la Peña (mandel) wrote :

Looks good, I launched the UI and everything worked as expected. Code looks good too.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'data/ui.glade'
2--- data/ui.glade 2010-08-27 20:13:59 +0000
3+++ data/ui.glade 2011-03-24 14:16:06 +0000
4@@ -264,36 +264,62 @@
5 </packing>
6 </child>
7 <child>
8- <object class="GtkHButtonBox" id="hbuttonbox1">
9+ <object class="GtkHBox" id="hbox2">
10 <property name="visible">True</property>
11- <property name="spacing">5</property>
12- <property name="layout_style">end</property>
13 <child>
14- <object class="GtkButton" id="join_cancel_button">
15- <property name="label">gtk-cancel</property>
16+ <object class="GtkLinkButton" id="login_button">
17+ <property name="label">login button</property>
18 <property name="visible">True</property>
19 <property name="can_focus">True</property>
20 <property name="receives_default">True</property>
21- <property name="use_stock">True</property>
22+ <property name="relief">none</property>
23+ <signal name="clicked" handler="on_sign_in_button_clicked" swapped="no"/>
24 </object>
25 <packing>
26 <property name="expand">False</property>
27- <property name="fill">False</property>
28+ <property name="fill">True</property>
29 <property name="position">0</property>
30 </packing>
31 </child>
32 <child>
33- <object class="GtkButton" id="join_ok_button">
34- <property name="label">gtk-go-forward</property>
35+ <object class="GtkHButtonBox" id="hbuttonbox1">
36 <property name="visible">True</property>
37- <property name="can_focus">True</property>
38- <property name="receives_default">True</property>
39- <property name="use_stock">True</property>
40- <signal name="clicked" handler="on_join_ok_button_clicked"/>
41+ <property name="can_focus">False</property>
42+ <property name="spacing">5</property>
43+ <property name="layout_style">end</property>
44+ <child>
45+ <object class="GtkButton" id="join_cancel_button">
46+ <property name="label">gtk-cancel</property>
47+ <property name="visible">True</property>
48+ <property name="can_focus">True</property>
49+ <property name="receives_default">True</property>
50+ <property name="use_stock">True</property>
51+ </object>
52+ <packing>
53+ <property name="expand">False</property>
54+ <property name="fill">False</property>
55+ <property name="position">0</property>
56+ </packing>
57+ </child>
58+ <child>
59+ <object class="GtkButton" id="join_ok_button">
60+ <property name="label">gtk-go-forward</property>
61+ <property name="visible">True</property>
62+ <property name="can_focus">True</property>
63+ <property name="receives_default">True</property>
64+ <property name="use_stock">True</property>
65+ <signal name="clicked" handler="on_join_ok_button_clicked" swapped="no"/>
66+ </object>
67+ <packing>
68+ <property name="expand">False</property>
69+ <property name="fill">False</property>
70+ <property name="position">1</property>
71+ </packing>
72+ </child>
73 </object>
74 <packing>
75 <property name="expand">False</property>
76- <property name="fill">False</property>
77+ <property name="pack_type">end</property>
78 <property name="position">1</property>
79 </packing>
80 </child>
81@@ -303,24 +329,6 @@
82 <property name="position">12</property>
83 </packing>
84 </child>
85- <child>
86- <object class="GtkLinkButton" id="login_button">
87- <property name="label" translatable="yes">login button</property>
88- <property name="visible">True</property>
89- <property name="can_focus">True</property>
90- <property name="receives_default">True</property>
91- <property name="has_tooltip">True</property>
92- <property name="relief">none</property>
93- <signal name="clicked" handler="on_sign_in_button_clicked"/>
94- </object>
95- <packing>
96- <property name="expand">False</property>
97- <property name="position">13</property>
98- </packing>
99- </child>
100- <child>
101- <placeholder/>
102- </child>
103 </object>
104 <object class="GtkVBox" id="processing_vbox">
105 <property name="visible">True</property>
106
107=== modified file 'ubuntu_sso/gui.py'
108--- ubuntu_sso/gui.py 2010-12-15 21:39:30 +0000
109+++ ubuntu_sso/gui.py 2011-03-24 14:16:06 +0000
110@@ -387,8 +387,6 @@
111 msg = 'UbuntuSSOClientGUI: failed set_transient_for win id %r'
112 logger.exception(msg, window_id)
113
114- # Hidding unused widgets to save some space (LP #627440).
115- self.name_entry.hide()
116 self.yes_to_updates_checkbutton.hide()
117
118 self.window.show()
119@@ -769,11 +767,10 @@
120
121 error = False
122
123- # Hidding unused widgets to save some space (LP #627440).
124- #name = self.name_entry.get_text()
125- #if not name:
126- # self.name_entry.set_warning(self.FIELD_REQUIRED)
127- # error = True
128+ name = self.name_entry.get_text()
129+ if not name:
130+ self.name_entry.set_warning(self.FIELD_REQUIRED)
131+ error = True
132
133 # check email
134 email1 = self.email1_entry.get_text()
135@@ -812,10 +809,11 @@
136 self.user_password = password1
137
138 logger.info('Calling register_user with email %r, password <hidden>,' \
139- ' captcha_id %r and captcha_solution %r.', email1,
140- self._captcha_id, captcha_solution)
141+ ' name %r, captcha_id %r and captcha_solution %r.', email1,
142+ name, self._captcha_id, captcha_solution)
143 f = self.backend.register_user
144- f(self.app_name, email1, password1, self._captcha_id, captcha_solution,
145+ f(self.app_name, email1, password1, name,
146+ self._captcha_id, captcha_solution,
147 reply_handler=NO_OP, error_handler=NO_OP)
148
149 def on_tc_button_clicked(self, *args, **kwargs):
150
151=== modified file 'ubuntu_sso/main.py'
152--- ubuntu_sso/main.py 2010-12-15 21:39:30 +0000
153+++ ubuntu_sso/main.py 2011-03-24 14:16:06 +0000
154@@ -171,11 +171,12 @@
155
156 return captcha['captcha_id']
157
158- def register_user(self, email, password, captcha_id, captcha_solution):
159+ def register_user(self, email, password, displayname,
160+ captcha_id, captcha_solution):
161 """Register a new user with 'email' and 'password'."""
162 logger.debug('register_user: email: %r password: <hidden>, '
163- 'captcha_id: %r, captcha_solution: %r',
164- email, captcha_id, captcha_solution)
165+ 'displayname: %r, captcha_id: %r, captcha_solution: %r',
166+ email, displayname, captcha_id, captcha_solution)
167 sso_service = self.sso_service_class(None, self.service_url)
168 if not self._valid_email(email):
169 logger.error('register_user: InvalidEmailError for email: %r',
170@@ -186,7 +187,9 @@
171 raise InvalidPasswordError()
172
173 result = sso_service.registrations.register(
174- email=email, password=password, captcha_id=captcha_id,
175+ email=email, password=password,
176+ displayname=displayname,
177+ captcha_id=captcha_id,
178 captcha_solution=captcha_solution)
179 logger.info('register_user: email: %r result: %r', email, result)
180
181@@ -377,13 +380,13 @@
182 'app_name "%s" and error %r', app_name, error)
183
184 @dbus.service.method(dbus_interface=DBUS_IFACE_USER_NAME,
185- in_signature='sssss')
186- def register_user(self, app_name, email, password,
187+ in_signature='ssssss')
188+ def register_user(self, app_name, email, password, name,
189 captcha_id, captcha_solution):
190 """Call the matching method in the processor."""
191 def f():
192 """Inner function that will be run in a thread."""
193- return self.processor.register_user(email, password,
194+ return self.processor.register_user(email, password, name,
195 captcha_id, captcha_solution)
196 blocking(f, app_name, self.UserRegistered, self.UserRegistrationError)
197
198
199=== modified file 'ubuntu_sso/tests/test_gui.py'
200--- ubuntu_sso/tests/test_gui.py 2010-11-03 17:43:17 +0000
201+++ ubuntu_sso/tests/test_gui.py 2011-03-24 14:16:06 +0000
202@@ -678,7 +678,7 @@
203 expected = 'register_user'
204 self.assertIn(expected, self.ui.backend._called)
205 self.assertEqual(self.ui.backend._called[expected],
206- ((APP_NAME, EMAIL, PASSWORD, CAPTCHA_ID,
207+ ((APP_NAME, EMAIL, PASSWORD, NAME, CAPTCHA_ID,
208 CAPTCHA_SOLUTION),
209 dict(reply_handler=gui.NO_OP,
210 error_handler=gui.NO_OP)))
211@@ -1163,11 +1163,6 @@
212 self.ui.FIELD_REQUIRED)
213 self.assertNotIn('register_user', self.ui.backend._called)
214
215- # Unused variable 'skip'
216- # pylint: disable=W0612
217- test_warning_is_shown_if_name_empty.skip = \
218- 'Unused for now, will be hidden to save space (LP: #627440).'
219-
220 def test_warning_is_shown_if_empty_email(self):
221 """A warning message is shown if emails are empty."""
222 self.ui.email1_entry.set_text('')
223
224=== modified file 'ubuntu_sso/tests/test_main.py'
225--- ubuntu_sso/tests/test_main.py 2010-12-15 21:39:30 +0000
226+++ ubuntu_sso/tests/test_main.py 2011-03-24 14:16:06 +0000
227@@ -1,3 +1,5 @@
228+# -*- coding: utf-8 -*-
229+#
230 # test_main - tests for ubuntu_sso.main
231 #
232 # Author: Natalia Bidart <natalia.bidart@canonical.com>
233@@ -63,6 +65,7 @@
234 EMAIL_ALREADY_REGISTERED = 'a@example.com'
235 EMAIL_TOKEN = 'B2Pgtf'
236 HELP = 'help text'
237+NAME = 'Juanito Pérez'
238 PASSWORD = 'be4tiFul'
239 RESET_PASSWORD_TOKEN = '8G5Wtq'
240 TOKEN = {u'consumer_key': u'xQ7xDAz',
241@@ -107,7 +110,8 @@
242 class FakedRegistrations(object):
243 """Fake the registrations service."""
244
245- def register(self, email, password, captcha_id, captcha_solution):
246+ def register(self, email, password, displayname,
247+ captcha_id, captcha_solution):
248 """Fake registration. Return a fix result."""
249 if email == EMAIL_ALREADY_REGISTERED:
250 return {'status': 'error',
251@@ -196,6 +200,7 @@
252 """Init."""
253 self.processor = SSOLoginProcessor(sso_service_class=FakedSSOServer)
254 self.register_kwargs = dict(email=EMAIL, password=PASSWORD,
255+ displayname=NAME,
256 captcha_id=CAPTCHA_ID,
257 captcha_solution=CAPTCHA_SOLUTION)
258 self.login_kwargs = dict(email=EMAIL, password=PASSWORD,
259@@ -510,8 +515,8 @@
260 """Test that the register_user method works ok."""
261 d = Deferred()
262 expected_result = "expected result"
263- self.create_mock_processor().register_user(EMAIL, PASSWORD, CAPTCHA_ID,
264- CAPTCHA_SOLUTION)
265+ self.create_mock_processor().register_user(EMAIL, PASSWORD, NAME,
266+ CAPTCHA_ID, CAPTCHA_SOLUTION)
267 self.mocker.result(expected_result)
268 self.patch(ubuntu_sso.main, "blocking", self.fake_ok_blocking)
269 self.mocker.replay()
270@@ -526,7 +531,7 @@
271 sso_login_processor_class=self.mockprocessorclass)
272 self.patch(client, "UserRegistered", verify)
273 self.patch(client, "UserRegistrationError", d.errback)
274- client.register_user(APP_NAME, EMAIL, PASSWORD, CAPTCHA_ID,
275+ client.register_user(APP_NAME, EMAIL, PASSWORD, NAME, CAPTCHA_ID,
276 CAPTCHA_SOLUTION)
277 return d
278
279@@ -534,8 +539,8 @@
280 """Test that the register_user method fails as expected."""
281 d = Deferred()
282 expected_result = "expected result"
283- self.create_mock_processor().register_user(EMAIL, PASSWORD, CAPTCHA_ID,
284- CAPTCHA_SOLUTION)
285+ self.create_mock_processor().register_user(EMAIL, PASSWORD, NAME,
286+ CAPTCHA_ID, CAPTCHA_SOLUTION)
287 self.mocker.result(expected_result)
288 self.patch(ubuntu_sso.main, "blocking", self.fake_err_blocking)
289 self.mocker.replay()
290@@ -550,7 +555,7 @@
291 sso_login_processor_class=self.mockprocessorclass)
292 self.patch(client, "UserRegistered", d.errback)
293 self.patch(client, "UserRegistrationError", verify)
294- client.register_user(APP_NAME, EMAIL, PASSWORD, CAPTCHA_ID,
295+ client.register_user(APP_NAME, EMAIL, PASSWORD, NAME, CAPTCHA_ID,
296 CAPTCHA_SOLUTION)
297 return d
298

Subscribers

People subscribed via source and target branches