Merge lp:~nataliabidart/ubuntu-sso-client/displayname-stable into lp:ubuntu-sso-client/stable-1-0
- displayname-stable
- Merge into 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 | ||||
Related bugs: |
|
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
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 | 264 | </packing> | 264 | </packing> |
6 | 265 | </child> | 265 | </child> |
7 | 266 | <child> | 266 | <child> |
9 | 267 | <object class="GtkHButtonBox" id="hbuttonbox1"> | 267 | <object class="GtkHBox" id="hbox2"> |
10 | 268 | <property name="visible">True</property> | 268 | <property name="visible">True</property> |
11 | 269 | <property name="spacing">5</property> | ||
12 | 270 | <property name="layout_style">end</property> | ||
13 | 271 | <child> | 269 | <child> |
16 | 272 | <object class="GtkButton" id="join_cancel_button"> | 270 | <object class="GtkLinkButton" id="login_button"> |
17 | 273 | <property name="label">gtk-cancel</property> | 271 | <property name="label">login button</property> |
18 | 274 | <property name="visible">True</property> | 272 | <property name="visible">True</property> |
19 | 275 | <property name="can_focus">True</property> | 273 | <property name="can_focus">True</property> |
20 | 276 | <property name="receives_default">True</property> | 274 | <property name="receives_default">True</property> |
22 | 277 | <property name="use_stock">True</property> | 275 | <property name="relief">none</property> |
23 | 276 | <signal name="clicked" handler="on_sign_in_button_clicked" swapped="no"/> | ||
24 | 278 | </object> | 277 | </object> |
25 | 279 | <packing> | 278 | <packing> |
26 | 280 | <property name="expand">False</property> | 279 | <property name="expand">False</property> |
28 | 281 | <property name="fill">False</property> | 280 | <property name="fill">True</property> |
29 | 282 | <property name="position">0</property> | 281 | <property name="position">0</property> |
30 | 283 | </packing> | 282 | </packing> |
31 | 284 | </child> | 283 | </child> |
32 | 285 | <child> | 284 | <child> |
35 | 286 | <object class="GtkButton" id="join_ok_button"> | 285 | <object class="GtkHButtonBox" id="hbuttonbox1"> |
34 | 287 | <property name="label">gtk-go-forward</property> | ||
36 | 288 | <property name="visible">True</property> | 286 | <property name="visible">True</property> |
41 | 289 | <property name="can_focus">True</property> | 287 | <property name="can_focus">False</property> |
42 | 290 | <property name="receives_default">True</property> | 288 | <property name="spacing">5</property> |
43 | 291 | <property name="use_stock">True</property> | 289 | <property name="layout_style">end</property> |
44 | 292 | <signal name="clicked" handler="on_join_ok_button_clicked"/> | 290 | <child> |
45 | 291 | <object class="GtkButton" id="join_cancel_button"> | ||
46 | 292 | <property name="label">gtk-cancel</property> | ||
47 | 293 | <property name="visible">True</property> | ||
48 | 294 | <property name="can_focus">True</property> | ||
49 | 295 | <property name="receives_default">True</property> | ||
50 | 296 | <property name="use_stock">True</property> | ||
51 | 297 | </object> | ||
52 | 298 | <packing> | ||
53 | 299 | <property name="expand">False</property> | ||
54 | 300 | <property name="fill">False</property> | ||
55 | 301 | <property name="position">0</property> | ||
56 | 302 | </packing> | ||
57 | 303 | </child> | ||
58 | 304 | <child> | ||
59 | 305 | <object class="GtkButton" id="join_ok_button"> | ||
60 | 306 | <property name="label">gtk-go-forward</property> | ||
61 | 307 | <property name="visible">True</property> | ||
62 | 308 | <property name="can_focus">True</property> | ||
63 | 309 | <property name="receives_default">True</property> | ||
64 | 310 | <property name="use_stock">True</property> | ||
65 | 311 | <signal name="clicked" handler="on_join_ok_button_clicked" swapped="no"/> | ||
66 | 312 | </object> | ||
67 | 313 | <packing> | ||
68 | 314 | <property name="expand">False</property> | ||
69 | 315 | <property name="fill">False</property> | ||
70 | 316 | <property name="position">1</property> | ||
71 | 317 | </packing> | ||
72 | 318 | </child> | ||
73 | 293 | </object> | 319 | </object> |
74 | 294 | <packing> | 320 | <packing> |
75 | 295 | <property name="expand">False</property> | 321 | <property name="expand">False</property> |
77 | 296 | <property name="fill">False</property> | 322 | <property name="pack_type">end</property> |
78 | 297 | <property name="position">1</property> | 323 | <property name="position">1</property> |
79 | 298 | </packing> | 324 | </packing> |
80 | 299 | </child> | 325 | </child> |
81 | @@ -303,24 +329,6 @@ | |||
82 | 303 | <property name="position">12</property> | 329 | <property name="position">12</property> |
83 | 304 | </packing> | 330 | </packing> |
84 | 305 | </child> | 331 | </child> |
85 | 306 | <child> | ||
86 | 307 | <object class="GtkLinkButton" id="login_button"> | ||
87 | 308 | <property name="label" translatable="yes">login button</property> | ||
88 | 309 | <property name="visible">True</property> | ||
89 | 310 | <property name="can_focus">True</property> | ||
90 | 311 | <property name="receives_default">True</property> | ||
91 | 312 | <property name="has_tooltip">True</property> | ||
92 | 313 | <property name="relief">none</property> | ||
93 | 314 | <signal name="clicked" handler="on_sign_in_button_clicked"/> | ||
94 | 315 | </object> | ||
95 | 316 | <packing> | ||
96 | 317 | <property name="expand">False</property> | ||
97 | 318 | <property name="position">13</property> | ||
98 | 319 | </packing> | ||
99 | 320 | </child> | ||
100 | 321 | <child> | ||
101 | 322 | <placeholder/> | ||
102 | 323 | </child> | ||
103 | 324 | </object> | 332 | </object> |
104 | 325 | <object class="GtkVBox" id="processing_vbox"> | 333 | <object class="GtkVBox" id="processing_vbox"> |
105 | 326 | <property name="visible">True</property> | 334 | <property name="visible">True</property> |
106 | 327 | 335 | ||
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 | 387 | msg = 'UbuntuSSOClientGUI: failed set_transient_for win id %r' | 387 | msg = 'UbuntuSSOClientGUI: failed set_transient_for win id %r' |
112 | 388 | logger.exception(msg, window_id) | 388 | logger.exception(msg, window_id) |
113 | 389 | 389 | ||
114 | 390 | # Hidding unused widgets to save some space (LP #627440). | ||
115 | 391 | self.name_entry.hide() | ||
116 | 392 | self.yes_to_updates_checkbutton.hide() | 390 | self.yes_to_updates_checkbutton.hide() |
117 | 393 | 391 | ||
118 | 394 | self.window.show() | 392 | self.window.show() |
119 | @@ -769,11 +767,10 @@ | |||
120 | 769 | 767 | ||
121 | 770 | error = False | 768 | error = False |
122 | 771 | 769 | ||
128 | 772 | # Hidding unused widgets to save some space (LP #627440). | 770 | name = self.name_entry.get_text() |
129 | 773 | #name = self.name_entry.get_text() | 771 | if not name: |
130 | 774 | #if not name: | 772 | self.name_entry.set_warning(self.FIELD_REQUIRED) |
131 | 775 | # self.name_entry.set_warning(self.FIELD_REQUIRED) | 773 | error = True |
127 | 776 | # error = True | ||
132 | 777 | 774 | ||
133 | 778 | # check email | 775 | # check email |
134 | 779 | email1 = self.email1_entry.get_text() | 776 | email1 = self.email1_entry.get_text() |
135 | @@ -812,10 +809,11 @@ | |||
136 | 812 | self.user_password = password1 | 809 | self.user_password = password1 |
137 | 813 | 810 | ||
138 | 814 | logger.info('Calling register_user with email %r, password <hidden>,' \ | 811 | logger.info('Calling register_user with email %r, password <hidden>,' \ |
141 | 815 | ' captcha_id %r and captcha_solution %r.', email1, | 812 | ' name %r, captcha_id %r and captcha_solution %r.', email1, |
142 | 816 | self._captcha_id, captcha_solution) | 813 | name, self._captcha_id, captcha_solution) |
143 | 817 | f = self.backend.register_user | 814 | f = self.backend.register_user |
145 | 818 | f(self.app_name, email1, password1, self._captcha_id, captcha_solution, | 815 | f(self.app_name, email1, password1, name, |
146 | 816 | self._captcha_id, captcha_solution, | ||
147 | 819 | reply_handler=NO_OP, error_handler=NO_OP) | 817 | reply_handler=NO_OP, error_handler=NO_OP) |
148 | 820 | 818 | ||
149 | 821 | def on_tc_button_clicked(self, *args, **kwargs): | 819 | def on_tc_button_clicked(self, *args, **kwargs): |
150 | 822 | 820 | ||
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 | 171 | 171 | ||
156 | 172 | return captcha['captcha_id'] | 172 | return captcha['captcha_id'] |
157 | 173 | 173 | ||
159 | 174 | def register_user(self, email, password, captcha_id, captcha_solution): | 174 | def register_user(self, email, password, displayname, |
160 | 175 | captcha_id, captcha_solution): | ||
161 | 175 | """Register a new user with 'email' and 'password'.""" | 176 | """Register a new user with 'email' and 'password'.""" |
162 | 176 | logger.debug('register_user: email: %r password: <hidden>, ' | 177 | logger.debug('register_user: email: %r password: <hidden>, ' |
165 | 177 | 'captcha_id: %r, captcha_solution: %r', | 178 | 'displayname: %r, captcha_id: %r, captcha_solution: %r', |
166 | 178 | email, captcha_id, captcha_solution) | 179 | email, displayname, captcha_id, captcha_solution) |
167 | 179 | sso_service = self.sso_service_class(None, self.service_url) | 180 | sso_service = self.sso_service_class(None, self.service_url) |
168 | 180 | if not self._valid_email(email): | 181 | if not self._valid_email(email): |
169 | 181 | logger.error('register_user: InvalidEmailError for email: %r', | 182 | logger.error('register_user: InvalidEmailError for email: %r', |
170 | @@ -186,7 +187,9 @@ | |||
171 | 186 | raise InvalidPasswordError() | 187 | raise InvalidPasswordError() |
172 | 187 | 188 | ||
173 | 188 | result = sso_service.registrations.register( | 189 | result = sso_service.registrations.register( |
175 | 189 | email=email, password=password, captcha_id=captcha_id, | 190 | email=email, password=password, |
176 | 191 | displayname=displayname, | ||
177 | 192 | captcha_id=captcha_id, | ||
178 | 190 | captcha_solution=captcha_solution) | 193 | captcha_solution=captcha_solution) |
179 | 191 | logger.info('register_user: email: %r result: %r', email, result) | 194 | logger.info('register_user: email: %r result: %r', email, result) |
180 | 192 | 195 | ||
181 | @@ -377,13 +380,13 @@ | |||
182 | 377 | 'app_name "%s" and error %r', app_name, error) | 380 | 'app_name "%s" and error %r', app_name, error) |
183 | 378 | 381 | ||
184 | 379 | @dbus.service.method(dbus_interface=DBUS_IFACE_USER_NAME, | 382 | @dbus.service.method(dbus_interface=DBUS_IFACE_USER_NAME, |
187 | 380 | in_signature='sssss') | 383 | in_signature='ssssss') |
188 | 381 | def register_user(self, app_name, email, password, | 384 | def register_user(self, app_name, email, password, name, |
189 | 382 | captcha_id, captcha_solution): | 385 | captcha_id, captcha_solution): |
190 | 383 | """Call the matching method in the processor.""" | 386 | """Call the matching method in the processor.""" |
191 | 384 | def f(): | 387 | def f(): |
192 | 385 | """Inner function that will be run in a thread.""" | 388 | """Inner function that will be run in a thread.""" |
194 | 386 | return self.processor.register_user(email, password, | 389 | return self.processor.register_user(email, password, name, |
195 | 387 | captcha_id, captcha_solution) | 390 | captcha_id, captcha_solution) |
196 | 388 | blocking(f, app_name, self.UserRegistered, self.UserRegistrationError) | 391 | blocking(f, app_name, self.UserRegistered, self.UserRegistrationError) |
197 | 389 | 392 | ||
198 | 390 | 393 | ||
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 | 678 | expected = 'register_user' | 678 | expected = 'register_user' |
204 | 679 | self.assertIn(expected, self.ui.backend._called) | 679 | self.assertIn(expected, self.ui.backend._called) |
205 | 680 | self.assertEqual(self.ui.backend._called[expected], | 680 | self.assertEqual(self.ui.backend._called[expected], |
207 | 681 | ((APP_NAME, EMAIL, PASSWORD, CAPTCHA_ID, | 681 | ((APP_NAME, EMAIL, PASSWORD, NAME, CAPTCHA_ID, |
208 | 682 | CAPTCHA_SOLUTION), | 682 | CAPTCHA_SOLUTION), |
209 | 683 | dict(reply_handler=gui.NO_OP, | 683 | dict(reply_handler=gui.NO_OP, |
210 | 684 | error_handler=gui.NO_OP))) | 684 | error_handler=gui.NO_OP))) |
211 | @@ -1163,11 +1163,6 @@ | |||
212 | 1163 | self.ui.FIELD_REQUIRED) | 1163 | self.ui.FIELD_REQUIRED) |
213 | 1164 | self.assertNotIn('register_user', self.ui.backend._called) | 1164 | self.assertNotIn('register_user', self.ui.backend._called) |
214 | 1165 | 1165 | ||
215 | 1166 | # Unused variable 'skip' | ||
216 | 1167 | # pylint: disable=W0612 | ||
217 | 1168 | test_warning_is_shown_if_name_empty.skip = \ | ||
218 | 1169 | 'Unused for now, will be hidden to save space (LP: #627440).' | ||
219 | 1170 | |||
220 | 1171 | def test_warning_is_shown_if_empty_email(self): | 1166 | def test_warning_is_shown_if_empty_email(self): |
221 | 1172 | """A warning message is shown if emails are empty.""" | 1167 | """A warning message is shown if emails are empty.""" |
222 | 1173 | self.ui.email1_entry.set_text('') | 1168 | self.ui.email1_entry.set_text('') |
223 | 1174 | 1169 | ||
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 | 1 | # -*- coding: utf-8 -*- | ||
229 | 2 | # | ||
230 | 1 | # test_main - tests for ubuntu_sso.main | 3 | # test_main - tests for ubuntu_sso.main |
231 | 2 | # | 4 | # |
232 | 3 | # Author: Natalia Bidart <natalia.bidart@canonical.com> | 5 | # Author: Natalia Bidart <natalia.bidart@canonical.com> |
233 | @@ -63,6 +65,7 @@ | |||
234 | 63 | EMAIL_ALREADY_REGISTERED = 'a@example.com' | 65 | EMAIL_ALREADY_REGISTERED = 'a@example.com' |
235 | 64 | EMAIL_TOKEN = 'B2Pgtf' | 66 | EMAIL_TOKEN = 'B2Pgtf' |
236 | 65 | HELP = 'help text' | 67 | HELP = 'help text' |
237 | 68 | NAME = 'Juanito Pérez' | ||
238 | 66 | PASSWORD = 'be4tiFul' | 69 | PASSWORD = 'be4tiFul' |
239 | 67 | RESET_PASSWORD_TOKEN = '8G5Wtq' | 70 | RESET_PASSWORD_TOKEN = '8G5Wtq' |
240 | 68 | TOKEN = {u'consumer_key': u'xQ7xDAz', | 71 | TOKEN = {u'consumer_key': u'xQ7xDAz', |
241 | @@ -107,7 +110,8 @@ | |||
242 | 107 | class FakedRegistrations(object): | 110 | class FakedRegistrations(object): |
243 | 108 | """Fake the registrations service.""" | 111 | """Fake the registrations service.""" |
244 | 109 | 112 | ||
246 | 110 | def register(self, email, password, captcha_id, captcha_solution): | 113 | def register(self, email, password, displayname, |
247 | 114 | captcha_id, captcha_solution): | ||
248 | 111 | """Fake registration. Return a fix result.""" | 115 | """Fake registration. Return a fix result.""" |
249 | 112 | if email == EMAIL_ALREADY_REGISTERED: | 116 | if email == EMAIL_ALREADY_REGISTERED: |
250 | 113 | return {'status': 'error', | 117 | return {'status': 'error', |
251 | @@ -196,6 +200,7 @@ | |||
252 | 196 | """Init.""" | 200 | """Init.""" |
253 | 197 | self.processor = SSOLoginProcessor(sso_service_class=FakedSSOServer) | 201 | self.processor = SSOLoginProcessor(sso_service_class=FakedSSOServer) |
254 | 198 | self.register_kwargs = dict(email=EMAIL, password=PASSWORD, | 202 | self.register_kwargs = dict(email=EMAIL, password=PASSWORD, |
255 | 203 | displayname=NAME, | ||
256 | 199 | captcha_id=CAPTCHA_ID, | 204 | captcha_id=CAPTCHA_ID, |
257 | 200 | captcha_solution=CAPTCHA_SOLUTION) | 205 | captcha_solution=CAPTCHA_SOLUTION) |
258 | 201 | self.login_kwargs = dict(email=EMAIL, password=PASSWORD, | 206 | self.login_kwargs = dict(email=EMAIL, password=PASSWORD, |
259 | @@ -510,8 +515,8 @@ | |||
260 | 510 | """Test that the register_user method works ok.""" | 515 | """Test that the register_user method works ok.""" |
261 | 511 | d = Deferred() | 516 | d = Deferred() |
262 | 512 | expected_result = "expected result" | 517 | expected_result = "expected result" |
265 | 513 | self.create_mock_processor().register_user(EMAIL, PASSWORD, CAPTCHA_ID, | 518 | self.create_mock_processor().register_user(EMAIL, PASSWORD, NAME, |
266 | 514 | CAPTCHA_SOLUTION) | 519 | CAPTCHA_ID, CAPTCHA_SOLUTION) |
267 | 515 | self.mocker.result(expected_result) | 520 | self.mocker.result(expected_result) |
268 | 516 | self.patch(ubuntu_sso.main, "blocking", self.fake_ok_blocking) | 521 | self.patch(ubuntu_sso.main, "blocking", self.fake_ok_blocking) |
269 | 517 | self.mocker.replay() | 522 | self.mocker.replay() |
270 | @@ -526,7 +531,7 @@ | |||
271 | 526 | sso_login_processor_class=self.mockprocessorclass) | 531 | sso_login_processor_class=self.mockprocessorclass) |
272 | 527 | self.patch(client, "UserRegistered", verify) | 532 | self.patch(client, "UserRegistered", verify) |
273 | 528 | self.patch(client, "UserRegistrationError", d.errback) | 533 | self.patch(client, "UserRegistrationError", d.errback) |
275 | 529 | client.register_user(APP_NAME, EMAIL, PASSWORD, CAPTCHA_ID, | 534 | client.register_user(APP_NAME, EMAIL, PASSWORD, NAME, CAPTCHA_ID, |
276 | 530 | CAPTCHA_SOLUTION) | 535 | CAPTCHA_SOLUTION) |
277 | 531 | return d | 536 | return d |
278 | 532 | 537 | ||
279 | @@ -534,8 +539,8 @@ | |||
280 | 534 | """Test that the register_user method fails as expected.""" | 539 | """Test that the register_user method fails as expected.""" |
281 | 535 | d = Deferred() | 540 | d = Deferred() |
282 | 536 | expected_result = "expected result" | 541 | expected_result = "expected result" |
285 | 537 | self.create_mock_processor().register_user(EMAIL, PASSWORD, CAPTCHA_ID, | 542 | self.create_mock_processor().register_user(EMAIL, PASSWORD, NAME, |
286 | 538 | CAPTCHA_SOLUTION) | 543 | CAPTCHA_ID, CAPTCHA_SOLUTION) |
287 | 539 | self.mocker.result(expected_result) | 544 | self.mocker.result(expected_result) |
288 | 540 | self.patch(ubuntu_sso.main, "blocking", self.fake_err_blocking) | 545 | self.patch(ubuntu_sso.main, "blocking", self.fake_err_blocking) |
289 | 541 | self.mocker.replay() | 546 | self.mocker.replay() |
290 | @@ -550,7 +555,7 @@ | |||
291 | 550 | sso_login_processor_class=self.mockprocessorclass) | 555 | sso_login_processor_class=self.mockprocessorclass) |
292 | 551 | self.patch(client, "UserRegistered", d.errback) | 556 | self.patch(client, "UserRegistered", d.errback) |
293 | 552 | self.patch(client, "UserRegistrationError", verify) | 557 | self.patch(client, "UserRegistrationError", verify) |
295 | 553 | client.register_user(APP_NAME, EMAIL, PASSWORD, CAPTCHA_ID, | 558 | client.register_user(APP_NAME, EMAIL, PASSWORD, NAME, CAPTCHA_ID, |
296 | 554 | CAPTCHA_SOLUTION) | 559 | CAPTCHA_SOLUTION) |
297 | 555 | return d | 560 | return d |
298 | 556 | 561 |
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.