Merge lp:~nataliabidart/ubuntu/maverick/ubuntu-sso-client/ubuntu-sso-client-1.0.9 into lp:ubuntu/maverick-proposed/ubuntu-sso-client

Proposed by Natalia Bidart on 2011-04-12
Status: Merged
Merged at revision: 21
Proposed branch: lp:~nataliabidart/ubuntu/maverick/ubuntu-sso-client/ubuntu-sso-client-1.0.9
Merge into: lp:ubuntu/maverick-proposed/ubuntu-sso-client
Diff against target: 714 lines (+178/-258)
10 files modified
PKG-INFO (+1/-1)
data/ui.glade (+40/-32)
debian/changelog (+10/-0)
po/ubuntu-sso-client.pot (+0/-179)
run-tests (+1/-1)
setup.py (+3/-2)
ubuntu_sso/gui.py (+10/-12)
ubuntu_sso/main.py (+33/-8)
ubuntu_sso/tests/test_gui.py (+13/-18)
ubuntu_sso/tests/test_main.py (+67/-5)
To merge this branch: bzr merge lp:~nataliabidart/ubuntu/maverick/ubuntu-sso-client/ubuntu-sso-client-1.0.9
Reviewer Review Type Date Requested Status
Ubuntu Sponsors Team 2011-04-12 Pending
Review via email: mp+57380@code.launchpad.net

Description of the change

  * New upstream release:
    [ Natalia B. Bidart <email address hidden> ]
      - Register now uses the 'displayname' field to pass it on to SSO as display name (LP: #709494).

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'PKG-INFO'
2--- PKG-INFO 2010-12-16 13:19:01 +0000
3+++ PKG-INFO 2011-04-12 19:05:52 +0000
4@@ -1,6 +1,6 @@
5 Metadata-Version: 1.1
6 Name: ubuntu-sso-client
7-Version: 1.0.8
8+Version: 1.0.9
9 Summary: Ubuntu Single Sign-On client
10 Home-page: https://launchpad.net/ubuntu-sso-client
11 Author: Natalia Bidart
12
13=== modified file 'data/ui.glade'
14--- data/ui.glade 2010-08-27 22:16:40 +0000
15+++ data/ui.glade 2011-04-12 19:05:52 +0000
16@@ -264,36 +264,62 @@
17 </packing>
18 </child>
19 <child>
20- <object class="GtkHButtonBox" id="hbuttonbox1">
21+ <object class="GtkHBox" id="hbox2">
22 <property name="visible">True</property>
23- <property name="spacing">5</property>
24- <property name="layout_style">end</property>
25 <child>
26- <object class="GtkButton" id="join_cancel_button">
27- <property name="label">gtk-cancel</property>
28+ <object class="GtkLinkButton" id="login_button">
29+ <property name="label">login button</property>
30 <property name="visible">True</property>
31 <property name="can_focus">True</property>
32 <property name="receives_default">True</property>
33- <property name="use_stock">True</property>
34+ <property name="relief">none</property>
35+ <signal name="clicked" handler="on_sign_in_button_clicked" swapped="no"/>
36 </object>
37 <packing>
38 <property name="expand">False</property>
39- <property name="fill">False</property>
40+ <property name="fill">True</property>
41 <property name="position">0</property>
42 </packing>
43 </child>
44 <child>
45- <object class="GtkButton" id="join_ok_button">
46- <property name="label">gtk-go-forward</property>
47+ <object class="GtkHButtonBox" id="hbuttonbox1">
48 <property name="visible">True</property>
49- <property name="can_focus">True</property>
50- <property name="receives_default">True</property>
51- <property name="use_stock">True</property>
52- <signal name="clicked" handler="on_join_ok_button_clicked"/>
53+ <property name="can_focus">False</property>
54+ <property name="spacing">5</property>
55+ <property name="layout_style">end</property>
56+ <child>
57+ <object class="GtkButton" id="join_cancel_button">
58+ <property name="label">gtk-cancel</property>
59+ <property name="visible">True</property>
60+ <property name="can_focus">True</property>
61+ <property name="receives_default">True</property>
62+ <property name="use_stock">True</property>
63+ </object>
64+ <packing>
65+ <property name="expand">False</property>
66+ <property name="fill">False</property>
67+ <property name="position">0</property>
68+ </packing>
69+ </child>
70+ <child>
71+ <object class="GtkButton" id="join_ok_button">
72+ <property name="label">gtk-go-forward</property>
73+ <property name="visible">True</property>
74+ <property name="can_focus">True</property>
75+ <property name="receives_default">True</property>
76+ <property name="use_stock">True</property>
77+ <signal name="clicked" handler="on_join_ok_button_clicked" swapped="no"/>
78+ </object>
79+ <packing>
80+ <property name="expand">False</property>
81+ <property name="fill">False</property>
82+ <property name="position">1</property>
83+ </packing>
84+ </child>
85 </object>
86 <packing>
87 <property name="expand">False</property>
88- <property name="fill">False</property>
89+ <property name="pack_type">end</property>
90 <property name="position">1</property>
91 </packing>
92 </child>
93@@ -303,24 +329,6 @@
94 <property name="position">12</property>
95 </packing>
96 </child>
97- <child>
98- <object class="GtkLinkButton" id="login_button">
99- <property name="label" translatable="yes">login button</property>
100- <property name="visible">True</property>
101- <property name="can_focus">True</property>
102- <property name="receives_default">True</property>
103- <property name="has_tooltip">True</property>
104- <property name="relief">none</property>
105- <signal name="clicked" handler="on_sign_in_button_clicked"/>
106- </object>
107- <packing>
108- <property name="expand">False</property>
109- <property name="position">13</property>
110- </packing>
111- </child>
112- <child>
113- <placeholder/>
114- </child>
115 </object>
116 <object class="GtkVBox" id="processing_vbox">
117 <property name="visible">True</property>
118
119=== modified file 'debian/changelog'
120--- debian/changelog 2010-12-16 13:19:01 +0000
121+++ debian/changelog 2011-04-12 19:05:52 +0000
122@@ -1,3 +1,13 @@
123+ubuntu-sso-client (1.0.9-0ubuntu1) UNRELEASED; urgency=low
124+
125+ * New upstream release:
126+
127+ [ Natalia B. Bidart <natalia.bidart@canonical.com> ]
128+ - Register now uses the 'displayname' field to pass it on to SSO as
129+ display name (LP: #709494).
130+
131+ -- Natalia Bidart (nessita) <nataliabidart@gmail.com> Tue, 29 Mar 2011 16:26:42 -0300
132+
133 ubuntu-sso-client (1.0.8-0ubuntu1) maverick-proposed; urgency=low
134
135 * New upstream release.
136
137=== removed file 'po/ubuntu-sso-client.pot'
138--- po/ubuntu-sso-client.pot 2010-12-16 13:19:01 +0000
139+++ po/ubuntu-sso-client.pot 1970-01-01 00:00:00 +0000
140@@ -1,179 +0,0 @@
141-# SOME DESCRIPTIVE TITLE.
142-# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
143-# This file is distributed under the same license as the PACKAGE package.
144-# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
145-#
146-#, fuzzy
147-msgid ""
148-msgstr ""
149-"Project-Id-Version: PACKAGE VERSION\n"
150-"Report-Msgid-Bugs-To: \n"
151-"POT-Creation-Date: 2010-12-16 12:42-0300\n"
152-"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
153-"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
154-"Language-Team: LANGUAGE <LL@li.org>\n"
155-"Language: \n"
156-"MIME-Version: 1.0\n"
157-"Content-Type: text/plain; charset=CHARSET\n"
158-"Content-Transfer-Encoding: 8bit\n"
159-
160-#: ../ubuntu_sso/gui.py:189
161-msgid "Type the characters above"
162-msgstr ""
163-
164-#: ../ubuntu_sso/gui.py:190
165-#, python-format
166-msgid "To connect this computer to %(app_name)s enter your details below."
167-msgstr ""
168-
169-#: ../ubuntu_sso/gui.py:192 ../ubuntu_sso/gui.py:203 ../ubuntu_sso/gui.py:221
170-msgid "Email address"
171-msgstr ""
172-
173-#: ../ubuntu_sso/gui.py:193
174-msgid "Re-type Email address"
175-msgstr ""
176-
177-#: ../ubuntu_sso/gui.py:194
178-msgid ""
179-"The email addresses don't match, please double check and try entering them "
180-"again."
181-msgstr ""
182-
183-#: ../ubuntu_sso/gui.py:196
184-msgid "The email must be a valid email address."
185-msgstr ""
186-
187-#: ../ubuntu_sso/gui.py:197
188-msgid "Enter code verification here"
189-msgstr ""
190-
191-#: ../ubuntu_sso/gui.py:198
192-msgid "This field is required."
193-msgstr ""
194-
195-#: ../ubuntu_sso/gui.py:199
196-msgid "I've forgotten my password"
197-msgstr ""
198-
199-#: ../ubuntu_sso/gui.py:200
200-#, python-format
201-msgid "Create %(app_name)s account"
202-msgstr ""
203-
204-#: ../ubuntu_sso/gui.py:201
205-msgid "Loading..."
206-msgstr ""
207-
208-#: ../ubuntu_sso/gui.py:202
209-msgid "Already have an account? Click here to sign in"
210-msgstr ""
211-
212-#: ../ubuntu_sso/gui.py:204
213-#, python-format
214-msgid "Connect to %(app_name)s"
215-msgstr ""
216-
217-#: ../ubuntu_sso/gui.py:205 ../ubuntu_sso/gui.py:210
218-msgid "Password"
219-msgstr ""
220-
221-#: ../ubuntu_sso/gui.py:206
222-msgid "Name"
223-msgstr ""
224-
225-#: ../ubuntu_sso/gui.py:207
226-msgid "Next"
227-msgstr ""
228-
229-#: ../ubuntu_sso/gui.py:208
230-msgid "One moment please..."
231-msgstr ""
232-
233-#: ../ubuntu_sso/gui.py:209
234-msgid "Your password was successfully changed."
235-msgstr ""
236-
237-#: ../ubuntu_sso/gui.py:211
238-msgid "Re-type Password"
239-msgstr ""
240-
241-#: ../ubuntu_sso/gui.py:212
242-msgid ""
243-"The password must have a minimum of 8 characters and include one uppercase "
244-"character and one number."
245-msgstr ""
246-
247-#: ../ubuntu_sso/gui.py:214
248-msgid ""
249-"The passwords don't match, please double check and try entering them again."
250-msgstr ""
251-
252-#: ../ubuntu_sso/gui.py:216
253-msgid "The password is too weak."
254-msgstr ""
255-
256-#: ../ubuntu_sso/gui.py:217
257-#, python-format
258-msgid "To reset your %(app_name)s password, enter your email address below:"
259-msgstr ""
260-
261-#: ../ubuntu_sso/gui.py:219
262-msgid "Reset password"
263-msgstr ""
264-
265-#: ../ubuntu_sso/gui.py:220
266-msgid "Reset code"
267-msgstr ""
268-
269-#: ../ubuntu_sso/gui.py:222
270-#, python-format
271-msgid ""
272-"A password reset code has been sent to %(email)s.\n"
273-"Please enter the code below along with your new password."
274-msgstr ""
275-
276-#: ../ubuntu_sso/gui.py:225
277-msgid "The process finished successfully. Congratulations!"
278-msgstr ""
279-
280-#: ../ubuntu_sso/gui.py:226
281-msgid "Terms & Conditions"
282-msgstr ""
283-
284-#: ../ubuntu_sso/gui.py:227
285-msgid "Agreeing to the Ubuntu One Terms & Conditions is required to subscribe."
286-msgstr ""
287-
288-#: ../ubuntu_sso/gui.py:229
289-msgid ""
290-"There was an error when trying to complete the process. Please check the "
291-"information and try again."
292-msgstr ""
293-
294-#: ../ubuntu_sso/gui.py:231
295-msgid "Enter verification code"
296-msgstr ""
297-
298-#: ../ubuntu_sso/gui.py:232
299-#, python-format
300-msgid ""
301-"Check %(email)s for an email from Ubuntu Single Sign On. This message "
302-"contains a verification code. Enter the code in the field below and click OK "
303-"to complete creating your %(app_name)s account"
304-msgstr ""
305-
306-#: ../ubuntu_sso/gui.py:237
307-#, python-format
308-msgid "I agree with the %(app_name)s "
309-msgstr ""
310-
311-#. Terms&Conditions button
312-#: ../ubuntu_sso/gui.py:238
313-#, python-format
314-msgid "Yes! Email me %(app_name)s tips and updates."
315-msgstr ""
316-
317-#: ../ubuntu_sso/gui.py:239
318-msgid "Reload"
319-msgstr ""
320
321=== modified file 'run-tests'
322--- run-tests 2010-09-08 19:25:02 +0000
323+++ run-tests 2011-04-12 19:05:52 +0000
324@@ -16,7 +16,7 @@
325 # with this program. If not, see <http://www.gnu.org/licenses/>.
326
327 `which xvfb-run` ./contrib/test "$@"
328-pylint contrib ubuntu_sso
329+pylint ubuntu_sso
330 if [ -x `which pep8` ]; then
331 pep8 --repeat bin/ contrib/ ubuntu_sso/
332 else
333
334=== modified file 'setup.py'
335--- setup.py 2010-12-16 13:19:01 +0000
336+++ setup.py 2011-04-12 19:05:52 +0000
337@@ -36,7 +36,8 @@
338 from distutils.command import clean, build
339
340 # Defining variables for various rules here, similar to a Makefile.am
341-CLEANFILES = ['data/com.ubuntu.sso.service']
342+CLEANFILES = ['data/com.ubuntu.sso.service', 'po/ubuntu-sso-client.pot',
343+ 'MANIFEST']
344
345
346 # XXX: This needs some serious cleanup
347@@ -86,7 +87,7 @@
348
349 DistUtilsExtra.auto.setup(
350 name='ubuntu-sso-client',
351- version='1.0.8',
352+ version='1.0.9',
353 license='GPL v3',
354 author='Natalia Bidart',
355 author_email='natalia.bidart@canonical.com',
356
357=== modified file 'ubuntu_sso/gui.py'
358--- ubuntu_sso/gui.py 2010-12-16 13:19:01 +0000
359+++ ubuntu_sso/gui.py 2011-04-12 19:05:52 +0000
360@@ -387,8 +387,6 @@
361 msg = 'UbuntuSSOClientGUI: failed set_transient_for win id %r'
362 logger.exception(msg, window_id)
363
364- # Hidding unused widgets to save some space (LP #627440).
365- self.name_entry.hide()
366 self.yes_to_updates_checkbutton.hide()
367
368 self.window.show()
369@@ -769,11 +767,10 @@
370
371 error = False
372
373- # Hidding unused widgets to save some space (LP #627440).
374- #name = self.name_entry.get_text()
375- #if not name:
376- # self.name_entry.set_warning(self.FIELD_REQUIRED)
377- # error = True
378+ name = self.name_entry.get_text()
379+ if not name:
380+ self.name_entry.set_warning(self.FIELD_REQUIRED)
381+ error = True
382
383 # check email
384 email1 = self.email1_entry.get_text()
385@@ -811,11 +808,12 @@
386 self.user_email = email1
387 self.user_password = password1
388
389- logger.info('Calling register_user with email %r, password <hidden>,' \
390- ' captcha_id %r and captcha_solution %r.', email1,
391- self._captcha_id, captcha_solution)
392- f = self.backend.register_user
393- f(self.app_name, email1, password1, self._captcha_id, captcha_solution,
394+ logger.info('Calling register_with_name with email %r, password, '
395+ '<hidden> name %r, captcha_id %r and captcha_solution %r.',
396+ email1, name, self._captcha_id, captcha_solution)
397+ f = self.backend.register_with_name
398+ f(self.app_name, email1, password1, name,
399+ self._captcha_id, captcha_solution,
400 reply_handler=NO_OP, error_handler=NO_OP)
401
402 def on_tc_button_clicked(self, *args, **kwargs):
403
404=== modified file 'ubuntu_sso/main.py'
405--- ubuntu_sso/main.py 2010-12-16 13:19:01 +0000
406+++ ubuntu_sso/main.py 2011-04-12 19:05:52 +0000
407@@ -171,24 +171,27 @@
408
409 return captcha['captcha_id']
410
411- def register_user(self, email, password, captcha_id, captcha_solution):
412+ def register_with_name(self, email, password, displayname,
413+ captcha_id, captcha_solution):
414 """Register a new user with 'email' and 'password'."""
415- logger.debug('register_user: email: %r password: <hidden>, '
416- 'captcha_id: %r, captcha_solution: %r',
417- email, captcha_id, captcha_solution)
418+ logger.debug('register_with_name: email: %r password: <hidden>, '
419+ 'displayname: %r, captcha_id: %r, captcha_solution: %r',
420+ email, displayname, captcha_id, captcha_solution)
421 sso_service = self.sso_service_class(None, self.service_url)
422 if not self._valid_email(email):
423- logger.error('register_user: InvalidEmailError for email: %r',
424+ logger.error('register_with_name: InvalidEmailError for email: %r',
425 email)
426 raise InvalidEmailError()
427 if not self._valid_password(password):
428- logger.error('register_user: InvalidPasswordError')
429+ logger.error('register_with_name: InvalidPasswordError')
430 raise InvalidPasswordError()
431
432 result = sso_service.registrations.register(
433- email=email, password=password, captcha_id=captcha_id,
434+ email=email, password=password,
435+ displayname=displayname,
436+ captcha_id=captcha_id,
437 captcha_solution=captcha_solution)
438- logger.info('register_user: email: %r result: %r', email, result)
439+ logger.info('register_with_name: email: %r result: %r', email, result)
440
441 if result['status'] == 'error':
442 errorsdict = self._format_webservice_errors(result['errors'])
443@@ -198,6 +201,17 @@
444 else:
445 return email
446
447+ def register_user(self, email, password,
448+ captcha_id, captcha_solution):
449+ """Register a new user with 'email' and 'password'."""
450+ logger.debug('register_user: email: %r password: <hidden>, '
451+ 'captcha_id: %r, captcha_solution: %r',
452+ email, captcha_id, captcha_solution)
453+ res = self.register_with_name(email, password, displayname='',
454+ captcha_id=captcha_id,
455+ captcha_solution=captcha_solution)
456+ return res
457+
458 def login(self, email, password, token_name):
459 """Login a user with 'email' and 'password'."""
460 logger.debug('login: email: %r password: <hidden>, token_name: %r',
461@@ -387,6 +401,17 @@
462 captcha_id, captcha_solution)
463 blocking(f, app_name, self.UserRegistered, self.UserRegistrationError)
464
465+ @dbus.service.method(dbus_interface=DBUS_IFACE_USER_NAME,
466+ in_signature='ssssss')
467+ def register_with_name(self, app_name, email, password, name,
468+ captcha_id, captcha_solution):
469+ """Call the matching method in the processor."""
470+ def f():
471+ """Inner function that will be run in a thread."""
472+ return self.processor.register_with_name(email, password, name,
473+ captcha_id, captcha_solution)
474+ blocking(f, app_name, self.UserRegistered, self.UserRegistrationError)
475+
476 # login signals
477 @dbus.service.signal(DBUS_IFACE_USER_NAME, signature="ss")
478 def LoggedIn(self, app_name, result):
479
480=== modified file 'ubuntu_sso/tests/test_gui.py'
481--- ubuntu_sso/tests/test_gui.py 2010-11-04 12:20:56 +0000
482+++ ubuntu_sso/tests/test_gui.py 2011-04-12 19:05:52 +0000
483@@ -63,7 +63,7 @@
484 self._args = args
485 self._kwargs = kwargs
486 self._called = {}
487- for i in ('generate_captcha', 'login', 'register_user',
488+ for i in ('generate_captcha', 'login', 'register_with_name',
489 'validate_email', 'request_password_reset_token',
490 'set_new_password'):
491 setattr(self, i, self._record_call(i))
492@@ -674,11 +674,11 @@
493 """Clicking 'join_ok_button' sends info to backend using 'register'."""
494 self.click_join_with_valid_data()
495
496- # assert register_user was called
497- expected = 'register_user'
498+ # assert register_with_name was called
499+ expected = 'register_with_name'
500 self.assertIn(expected, self.ui.backend._called)
501 self.assertEqual(self.ui.backend._called[expected],
502- ((APP_NAME, EMAIL, PASSWORD, CAPTCHA_ID,
503+ ((APP_NAME, EMAIL, PASSWORD, NAME, CAPTCHA_ID,
504 CAPTCHA_SOLUTION),
505 dict(reply_handler=gui.NO_OP,
506 error_handler=gui.NO_OP)))
507@@ -1161,12 +1161,7 @@
508
509 self.assert_correct_entry_warning(self.ui.name_entry,
510 self.ui.FIELD_REQUIRED)
511- self.assertNotIn('register_user', self.ui.backend._called)
512-
513- # Unused variable 'skip'
514- # pylint: disable=W0612
515- test_warning_is_shown_if_name_empty.skip = \
516- 'Unused for now, will be hidden to save space (LP: #627440).'
517+ self.assertNotIn('register_with_name', self.ui.backend._called)
518
519 def test_warning_is_shown_if_empty_email(self):
520 """A warning message is shown if emails are empty."""
521@@ -1179,7 +1174,7 @@
522 self.ui.FIELD_REQUIRED)
523 self.assert_correct_entry_warning(self.ui.email2_entry,
524 self.ui.FIELD_REQUIRED)
525- self.assertNotIn('register_user', self.ui.backend._called)
526+ self.assertNotIn('register_with_name', self.ui.backend._called)
527
528 def test_warning_is_shown_if_email_mismatch(self):
529 """A warning message is shown if emails doesn't match."""
530@@ -1192,7 +1187,7 @@
531 self.ui.EMAIL_MISMATCH)
532 self.assert_correct_entry_warning(self.ui.email2_entry,
533 self.ui.EMAIL_MISMATCH)
534- self.assertNotIn('register_user', self.ui.backend._called)
535+ self.assertNotIn('register_with_name', self.ui.backend._called)
536
537 def test_warning_is_shown_if_invalid_email(self):
538 """A warning message is shown if email is invalid."""
539@@ -1205,7 +1200,7 @@
540 self.ui.EMAIL_INVALID)
541 self.assert_correct_entry_warning(self.ui.email2_entry,
542 self.ui.EMAIL_INVALID)
543- self.assertNotIn('register_user', self.ui.backend._called)
544+ self.assertNotIn('register_with_name', self.ui.backend._called)
545
546 def test_password_help_is_always_shown(self):
547 """Password help text is correctly displayed."""
548@@ -1213,7 +1208,7 @@
549 'password help text is visible.')
550 self.assertEqual(self.ui.password_help_label.get_text(),
551 self.ui.PASSWORD_HELP)
552- self.assertNotIn('register_user', self.ui.backend._called)
553+ self.assertNotIn('register_with_name', self.ui.backend._called)
554
555 def test_warning_is_shown_if_password_mismatch(self):
556 """A warning message is shown if password doesn't match."""
557@@ -1226,7 +1221,7 @@
558 self.ui.PASSWORD_MISMATCH)
559 self.assert_correct_entry_warning(self.ui.password2_entry,
560 self.ui.PASSWORD_MISMATCH)
561- self.assertNotIn('register_user', self.ui.backend._called)
562+ self.assertNotIn('register_with_name', self.ui.backend._called)
563
564 def test_warning_is_shown_if_password_too_weak(self):
565 """A warning message is shown if password is too weak."""
566@@ -1241,7 +1236,7 @@
567 self.ui.PASSWORD_TOO_WEAK)
568 self.assert_correct_entry_warning(self.ui.password2_entry,
569 self.ui.PASSWORD_TOO_WEAK)
570- self.assertNotIn('register_user', self.ui.backend._called)
571+ self.assertNotIn('register_with_name', self.ui.backend._called)
572
573 def test_warning_is_shown_if_tc_not_accepted(self):
574 """A warning message is shown if TC are not accepted."""
575@@ -1252,7 +1247,7 @@
576
577 self.assert_correct_label_warning(self.ui.tc_warning_label,
578 self.ui.TC_NOT_ACCEPTED)
579- self.assertNotIn('register_user', self.ui.backend._called)
580+ self.assertNotIn('register_with_name', self.ui.backend._called)
581
582 def test_warning_is_shown_if_not_captcha_solution(self):
583 """A warning message is shown if TC are not accepted."""
584@@ -1263,7 +1258,7 @@
585
586 self.assert_correct_entry_warning(self.ui.captcha_solution_entry,
587 self.ui.FIELD_REQUIRED)
588- self.assertNotIn('register_user', self.ui.backend._called)
589+ self.assertNotIn('register_with_name', self.ui.backend._called)
590
591 def test_no_warning_messages_if_valid_data(self):
592 """No warning messages are shown if the data is valid."""
593
594=== modified file 'ubuntu_sso/tests/test_main.py'
595--- ubuntu_sso/tests/test_main.py 2010-12-16 13:19:01 +0000
596+++ ubuntu_sso/tests/test_main.py 2011-04-12 19:05:52 +0000
597@@ -1,3 +1,5 @@
598+# -*- coding: utf-8 -*-
599+#
600 # test_main - tests for ubuntu_sso.main
601 #
602 # Author: Natalia Bidart <natalia.bidart@canonical.com>
603@@ -63,6 +65,7 @@
604 EMAIL_ALREADY_REGISTERED = 'a@example.com'
605 EMAIL_TOKEN = 'B2Pgtf'
606 HELP = 'help text'
607+NAME = 'Juanito PĂ©rez'
608 PASSWORD = 'be4tiFul'
609 RESET_PASSWORD_TOKEN = '8G5Wtq'
610 TOKEN = {u'consumer_key': u'xQ7xDAz',
611@@ -107,7 +110,8 @@
612 class FakedRegistrations(object):
613 """Fake the registrations service."""
614
615- def register(self, email, password, captcha_id, captcha_solution):
616+ def register(self, email, password, displayname,
617+ captcha_id, captcha_solution):
618 """Fake registration. Return a fix result."""
619 if email == EMAIL_ALREADY_REGISTERED:
620 return {'status': 'error',
621@@ -399,6 +403,16 @@
622 self.assertIn('Received invalid reply: %s' % STATUS_UNKNOWN, exc)
623
624
625+class SSORegistrationWithNameTestCase(SSOLoginProcessorTestCase):
626+ """Test suite for the SSO login processor for register_with_name."""
627+
628+ def setUp(self):
629+ """Init."""
630+ super(SSORegistrationWithNameTestCase, self).setUp()
631+ self.register_kwargs['displayname'] = NAME
632+ self.processor.register_user = self.processor.register_with_name
633+
634+
635 class BlockingSampleException(Exception):
636 """The exception that will be thrown by the fake blocking."""
637
638@@ -510,8 +524,8 @@
639 """Test that the register_user method works ok."""
640 d = Deferred()
641 expected_result = "expected result"
642- self.create_mock_processor().register_user(EMAIL, PASSWORD, CAPTCHA_ID,
643- CAPTCHA_SOLUTION)
644+ self.create_mock_processor().register_user(EMAIL, PASSWORD,
645+ CAPTCHA_ID, CAPTCHA_SOLUTION)
646 self.mocker.result(expected_result)
647 self.patch(ubuntu_sso.main, "blocking", self.fake_ok_blocking)
648 self.mocker.replay()
649@@ -534,8 +548,8 @@
650 """Test that the register_user method fails as expected."""
651 d = Deferred()
652 expected_result = "expected result"
653- self.create_mock_processor().register_user(EMAIL, PASSWORD, CAPTCHA_ID,
654- CAPTCHA_SOLUTION)
655+ self.create_mock_processor().register_user(EMAIL, PASSWORD,
656+ CAPTCHA_ID, CAPTCHA_SOLUTION)
657 self.mocker.result(expected_result)
658 self.patch(ubuntu_sso.main, "blocking", self.fake_err_blocking)
659 self.mocker.replay()
660@@ -554,6 +568,54 @@
661 CAPTCHA_SOLUTION)
662 return d
663
664+ def test_register_with_name(self):
665+ """Test that the register_with_name method works ok."""
666+ d = Deferred()
667+ expected_result = "expected result"
668+ self.create_mock_processor().register_with_name(EMAIL, PASSWORD, NAME,
669+ CAPTCHA_ID, CAPTCHA_SOLUTION)
670+ self.mocker.result(expected_result)
671+ self.patch(ubuntu_sso.main, "blocking", self.fake_ok_blocking)
672+ self.mocker.replay()
673+
674+ def verify(app_name, result):
675+ """The actual test."""
676+ self.assertEqual(result, expected_result)
677+ self.assertEqual(app_name, APP_NAME)
678+ d.callback(result)
679+
680+ client = SSOLogin(self.mockbusname,
681+ sso_login_processor_class=self.mockprocessorclass)
682+ self.patch(client, "UserRegistered", verify)
683+ self.patch(client, "UserRegistrationError", d.errback)
684+ client.register_with_name(APP_NAME, EMAIL, PASSWORD, NAME, CAPTCHA_ID,
685+ CAPTCHA_SOLUTION)
686+ return d
687+
688+ def test_register_with_name_error(self):
689+ """Test that the register_with_name method fails as expected."""
690+ d = Deferred()
691+ expected_result = "expected result"
692+ self.create_mock_processor().register_with_name(EMAIL, PASSWORD, NAME,
693+ CAPTCHA_ID, CAPTCHA_SOLUTION)
694+ self.mocker.result(expected_result)
695+ self.patch(ubuntu_sso.main, "blocking", self.fake_err_blocking)
696+ self.mocker.replay()
697+
698+ def verify(app_name, errdict):
699+ """The actual test."""
700+ self.assertEqual(errdict["errtype"], "BlockingSampleException")
701+ self.assertEqual(app_name, APP_NAME)
702+ d.callback("Ok")
703+
704+ client = SSOLogin(self.mockbusname,
705+ sso_login_processor_class=self.mockprocessorclass)
706+ self.patch(client, "UserRegistered", d.errback)
707+ self.patch(client, "UserRegistrationError", verify)
708+ client.register_with_name(APP_NAME, EMAIL, PASSWORD, NAME, CAPTCHA_ID,
709+ CAPTCHA_SOLUTION)
710+ return d
711+
712 def test_login(self):
713 """Test that the login method works ok."""
714 d = Deferred()

Subscribers

People subscribed via source and target branches