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
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 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
=== modified file 'PKG-INFO'
--- PKG-INFO 2010-12-16 13:19:01 +0000
+++ PKG-INFO 2011-04-12 19:05:52 +0000
@@ -1,6 +1,6 @@
1Metadata-Version: 1.11Metadata-Version: 1.1
2Name: ubuntu-sso-client2Name: ubuntu-sso-client
3Version: 1.0.83Version: 1.0.9
4Summary: Ubuntu Single Sign-On client4Summary: Ubuntu Single Sign-On client
5Home-page: https://launchpad.net/ubuntu-sso-client5Home-page: https://launchpad.net/ubuntu-sso-client
6Author: Natalia Bidart6Author: Natalia Bidart
77
=== modified file 'data/ui.glade'
--- data/ui.glade 2010-08-27 22:16:40 +0000
+++ data/ui.glade 2011-04-12 19:05:52 +0000
@@ -264,36 +264,62 @@
264 </packing>264 </packing>
265 </child>265 </child>
266 <child>266 <child>
267 <object class="GtkHButtonBox" id="hbuttonbox1">267 <object class="GtkHBox" id="hbox2">
268 <property name="visible">True</property>268 <property name="visible">True</property>
269 <property name="spacing">5</property>
270 <property name="layout_style">end</property>
271 <child>269 <child>
272 <object class="GtkButton" id="join_cancel_button">270 <object class="GtkLinkButton" id="login_button">
273 <property name="label">gtk-cancel</property>271 <property name="label">login button</property>
274 <property name="visible">True</property>272 <property name="visible">True</property>
275 <property name="can_focus">True</property>273 <property name="can_focus">True</property>
276 <property name="receives_default">True</property>274 <property name="receives_default">True</property>
277 <property name="use_stock">True</property>275 <property name="relief">none</property>
276 <signal name="clicked" handler="on_sign_in_button_clicked" swapped="no"/>
278 </object>277 </object>
279 <packing>278 <packing>
280 <property name="expand">False</property>279 <property name="expand">False</property>
281 <property name="fill">False</property>280 <property name="fill">True</property>
282 <property name="position">0</property>281 <property name="position">0</property>
283 </packing>282 </packing>
284 </child>283 </child>
285 <child>284 <child>
286 <object class="GtkButton" id="join_ok_button">285 <object class="GtkHButtonBox" id="hbuttonbox1">
287 <property name="label">gtk-go-forward</property>
288 <property name="visible">True</property>286 <property name="visible">True</property>
289 <property name="can_focus">True</property>287 <property name="can_focus">False</property>
290 <property name="receives_default">True</property>288 <property name="spacing">5</property>
291 <property name="use_stock">True</property>289 <property name="layout_style">end</property>
292 <signal name="clicked" handler="on_join_ok_button_clicked"/>290 <child>
291 <object class="GtkButton" id="join_cancel_button">
292 <property name="label">gtk-cancel</property>
293 <property name="visible">True</property>
294 <property name="can_focus">True</property>
295 <property name="receives_default">True</property>
296 <property name="use_stock">True</property>
297 </object>
298 <packing>
299 <property name="expand">False</property>
300 <property name="fill">False</property>
301 <property name="position">0</property>
302 </packing>
303 </child>
304 <child>
305 <object class="GtkButton" id="join_ok_button">
306 <property name="label">gtk-go-forward</property>
307 <property name="visible">True</property>
308 <property name="can_focus">True</property>
309 <property name="receives_default">True</property>
310 <property name="use_stock">True</property>
311 <signal name="clicked" handler="on_join_ok_button_clicked" swapped="no"/>
312 </object>
313 <packing>
314 <property name="expand">False</property>
315 <property name="fill">False</property>
316 <property name="position">1</property>
317 </packing>
318 </child>
293 </object>319 </object>
294 <packing>320 <packing>
295 <property name="expand">False</property>321 <property name="expand">False</property>
296 <property name="fill">False</property>322 <property name="pack_type">end</property>
297 <property name="position">1</property>323 <property name="position">1</property>
298 </packing>324 </packing>
299 </child>325 </child>
@@ -303,24 +329,6 @@
303 <property name="position">12</property>329 <property name="position">12</property>
304 </packing>330 </packing>
305 </child>331 </child>
306 <child>
307 <object class="GtkLinkButton" id="login_button">
308 <property name="label" translatable="yes">login button</property>
309 <property name="visible">True</property>
310 <property name="can_focus">True</property>
311 <property name="receives_default">True</property>
312 <property name="has_tooltip">True</property>
313 <property name="relief">none</property>
314 <signal name="clicked" handler="on_sign_in_button_clicked"/>
315 </object>
316 <packing>
317 <property name="expand">False</property>
318 <property name="position">13</property>
319 </packing>
320 </child>
321 <child>
322 <placeholder/>
323 </child>
324 </object>332 </object>
325 <object class="GtkVBox" id="processing_vbox">333 <object class="GtkVBox" id="processing_vbox">
326 <property name="visible">True</property>334 <property name="visible">True</property>
327335
=== modified file 'debian/changelog'
--- debian/changelog 2010-12-16 13:19:01 +0000
+++ debian/changelog 2011-04-12 19:05:52 +0000
@@ -1,3 +1,13 @@
1ubuntu-sso-client (1.0.9-0ubuntu1) UNRELEASED; urgency=low
2
3 * New upstream release:
4
5 [ Natalia B. Bidart <natalia.bidart@canonical.com> ]
6 - Register now uses the 'displayname' field to pass it on to SSO as
7 display name (LP: #709494).
8
9 -- Natalia Bidart (nessita) <nataliabidart@gmail.com> Tue, 29 Mar 2011 16:26:42 -0300
10
1ubuntu-sso-client (1.0.8-0ubuntu1) maverick-proposed; urgency=low11ubuntu-sso-client (1.0.8-0ubuntu1) maverick-proposed; urgency=low
212
3 * New upstream release.13 * New upstream release.
414
=== removed file 'po/ubuntu-sso-client.pot'
--- po/ubuntu-sso-client.pot 2010-12-16 13:19:01 +0000
+++ po/ubuntu-sso-client.pot 1970-01-01 00:00:00 +0000
@@ -1,179 +0,0 @@
1# SOME DESCRIPTIVE TITLE.
2# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
3# This file is distributed under the same license as the PACKAGE package.
4# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
5#
6#, fuzzy
7msgid ""
8msgstr ""
9"Project-Id-Version: PACKAGE VERSION\n"
10"Report-Msgid-Bugs-To: \n"
11"POT-Creation-Date: 2010-12-16 12:42-0300\n"
12"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
13"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
14"Language-Team: LANGUAGE <LL@li.org>\n"
15"Language: \n"
16"MIME-Version: 1.0\n"
17"Content-Type: text/plain; charset=CHARSET\n"
18"Content-Transfer-Encoding: 8bit\n"
19
20#: ../ubuntu_sso/gui.py:189
21msgid "Type the characters above"
22msgstr ""
23
24#: ../ubuntu_sso/gui.py:190
25#, python-format
26msgid "To connect this computer to %(app_name)s enter your details below."
27msgstr ""
28
29#: ../ubuntu_sso/gui.py:192 ../ubuntu_sso/gui.py:203 ../ubuntu_sso/gui.py:221
30msgid "Email address"
31msgstr ""
32
33#: ../ubuntu_sso/gui.py:193
34msgid "Re-type Email address"
35msgstr ""
36
37#: ../ubuntu_sso/gui.py:194
38msgid ""
39"The email addresses don't match, please double check and try entering them "
40"again."
41msgstr ""
42
43#: ../ubuntu_sso/gui.py:196
44msgid "The email must be a valid email address."
45msgstr ""
46
47#: ../ubuntu_sso/gui.py:197
48msgid "Enter code verification here"
49msgstr ""
50
51#: ../ubuntu_sso/gui.py:198
52msgid "This field is required."
53msgstr ""
54
55#: ../ubuntu_sso/gui.py:199
56msgid "I've forgotten my password"
57msgstr ""
58
59#: ../ubuntu_sso/gui.py:200
60#, python-format
61msgid "Create %(app_name)s account"
62msgstr ""
63
64#: ../ubuntu_sso/gui.py:201
65msgid "Loading..."
66msgstr ""
67
68#: ../ubuntu_sso/gui.py:202
69msgid "Already have an account? Click here to sign in"
70msgstr ""
71
72#: ../ubuntu_sso/gui.py:204
73#, python-format
74msgid "Connect to %(app_name)s"
75msgstr ""
76
77#: ../ubuntu_sso/gui.py:205 ../ubuntu_sso/gui.py:210
78msgid "Password"
79msgstr ""
80
81#: ../ubuntu_sso/gui.py:206
82msgid "Name"
83msgstr ""
84
85#: ../ubuntu_sso/gui.py:207
86msgid "Next"
87msgstr ""
88
89#: ../ubuntu_sso/gui.py:208
90msgid "One moment please..."
91msgstr ""
92
93#: ../ubuntu_sso/gui.py:209
94msgid "Your password was successfully changed."
95msgstr ""
96
97#: ../ubuntu_sso/gui.py:211
98msgid "Re-type Password"
99msgstr ""
100
101#: ../ubuntu_sso/gui.py:212
102msgid ""
103"The password must have a minimum of 8 characters and include one uppercase "
104"character and one number."
105msgstr ""
106
107#: ../ubuntu_sso/gui.py:214
108msgid ""
109"The passwords don't match, please double check and try entering them again."
110msgstr ""
111
112#: ../ubuntu_sso/gui.py:216
113msgid "The password is too weak."
114msgstr ""
115
116#: ../ubuntu_sso/gui.py:217
117#, python-format
118msgid "To reset your %(app_name)s password, enter your email address below:"
119msgstr ""
120
121#: ../ubuntu_sso/gui.py:219
122msgid "Reset password"
123msgstr ""
124
125#: ../ubuntu_sso/gui.py:220
126msgid "Reset code"
127msgstr ""
128
129#: ../ubuntu_sso/gui.py:222
130#, python-format
131msgid ""
132"A password reset code has been sent to %(email)s.\n"
133"Please enter the code below along with your new password."
134msgstr ""
135
136#: ../ubuntu_sso/gui.py:225
137msgid "The process finished successfully. Congratulations!"
138msgstr ""
139
140#: ../ubuntu_sso/gui.py:226
141msgid "Terms & Conditions"
142msgstr ""
143
144#: ../ubuntu_sso/gui.py:227
145msgid "Agreeing to the Ubuntu One Terms & Conditions is required to subscribe."
146msgstr ""
147
148#: ../ubuntu_sso/gui.py:229
149msgid ""
150"There was an error when trying to complete the process. Please check the "
151"information and try again."
152msgstr ""
153
154#: ../ubuntu_sso/gui.py:231
155msgid "Enter verification code"
156msgstr ""
157
158#: ../ubuntu_sso/gui.py:232
159#, python-format
160msgid ""
161"Check %(email)s for an email from Ubuntu Single Sign On. This message "
162"contains a verification code. Enter the code in the field below and click OK "
163"to complete creating your %(app_name)s account"
164msgstr ""
165
166#: ../ubuntu_sso/gui.py:237
167#, python-format
168msgid "I agree with the %(app_name)s "
169msgstr ""
170
171#. Terms&Conditions button
172#: ../ubuntu_sso/gui.py:238
173#, python-format
174msgid "Yes! Email me %(app_name)s tips and updates."
175msgstr ""
176
177#: ../ubuntu_sso/gui.py:239
178msgid "Reload"
179msgstr ""
1800
=== modified file 'run-tests'
--- run-tests 2010-09-08 19:25:02 +0000
+++ run-tests 2011-04-12 19:05:52 +0000
@@ -16,7 +16,7 @@
16# with this program. If not, see <http://www.gnu.org/licenses/>.16# with this program. If not, see <http://www.gnu.org/licenses/>.
1717
18`which xvfb-run` ./contrib/test "$@"18`which xvfb-run` ./contrib/test "$@"
19pylint contrib ubuntu_sso19pylint ubuntu_sso
20if [ -x `which pep8` ]; then20if [ -x `which pep8` ]; then
21 pep8 --repeat bin/ contrib/ ubuntu_sso/21 pep8 --repeat bin/ contrib/ ubuntu_sso/
22else22else
2323
=== modified file 'setup.py'
--- setup.py 2010-12-16 13:19:01 +0000
+++ setup.py 2011-04-12 19:05:52 +0000
@@ -36,7 +36,8 @@
36from distutils.command import clean, build36from distutils.command import clean, build
3737
38# Defining variables for various rules here, similar to a Makefile.am38# Defining variables for various rules here, similar to a Makefile.am
39CLEANFILES = ['data/com.ubuntu.sso.service']39CLEANFILES = ['data/com.ubuntu.sso.service', 'po/ubuntu-sso-client.pot',
40 'MANIFEST']
4041
4142
42# XXX: This needs some serious cleanup43# XXX: This needs some serious cleanup
@@ -86,7 +87,7 @@
8687
87DistUtilsExtra.auto.setup(88DistUtilsExtra.auto.setup(
88 name='ubuntu-sso-client',89 name='ubuntu-sso-client',
89 version='1.0.8',90 version='1.0.9',
90 license='GPL v3',91 license='GPL v3',
91 author='Natalia Bidart',92 author='Natalia Bidart',
92 author_email='natalia.bidart@canonical.com',93 author_email='natalia.bidart@canonical.com',
9394
=== modified file 'ubuntu_sso/gui.py'
--- ubuntu_sso/gui.py 2010-12-16 13:19:01 +0000
+++ ubuntu_sso/gui.py 2011-04-12 19:05:52 +0000
@@ -387,8 +387,6 @@
387 msg = 'UbuntuSSOClientGUI: failed set_transient_for win id %r'387 msg = 'UbuntuSSOClientGUI: failed set_transient_for win id %r'
388 logger.exception(msg, window_id)388 logger.exception(msg, window_id)
389389
390 # Hidding unused widgets to save some space (LP #627440).
391 self.name_entry.hide()
392 self.yes_to_updates_checkbutton.hide()390 self.yes_to_updates_checkbutton.hide()
393391
394 self.window.show()392 self.window.show()
@@ -769,11 +767,10 @@
769767
770 error = False768 error = False
771769
772 # Hidding unused widgets to save some space (LP #627440).770 name = self.name_entry.get_text()
773 #name = self.name_entry.get_text()771 if not name:
774 #if not name:772 self.name_entry.set_warning(self.FIELD_REQUIRED)
775 # self.name_entry.set_warning(self.FIELD_REQUIRED)773 error = True
776 # error = True
777774
778 # check email775 # check email
779 email1 = self.email1_entry.get_text()776 email1 = self.email1_entry.get_text()
@@ -811,11 +808,12 @@
811 self.user_email = email1808 self.user_email = email1
812 self.user_password = password1809 self.user_password = password1
813810
814 logger.info('Calling register_user with email %r, password <hidden>,' \811 logger.info('Calling register_with_name with email %r, password, '
815 ' captcha_id %r and captcha_solution %r.', email1,812 '<hidden> name %r, captcha_id %r and captcha_solution %r.',
816 self._captcha_id, captcha_solution)813 email1, name, self._captcha_id, captcha_solution)
817 f = self.backend.register_user814 f = self.backend.register_with_name
818 f(self.app_name, email1, password1, self._captcha_id, captcha_solution,815 f(self.app_name, email1, password1, name,
816 self._captcha_id, captcha_solution,
819 reply_handler=NO_OP, error_handler=NO_OP)817 reply_handler=NO_OP, error_handler=NO_OP)
820818
821 def on_tc_button_clicked(self, *args, **kwargs):819 def on_tc_button_clicked(self, *args, **kwargs):
822820
=== modified file 'ubuntu_sso/main.py'
--- ubuntu_sso/main.py 2010-12-16 13:19:01 +0000
+++ ubuntu_sso/main.py 2011-04-12 19:05:52 +0000
@@ -171,24 +171,27 @@
171171
172 return captcha['captcha_id']172 return captcha['captcha_id']
173173
174 def register_user(self, email, password, captcha_id, captcha_solution):174 def register_with_name(self, email, password, displayname,
175 captcha_id, captcha_solution):
175 """Register a new user with 'email' and 'password'."""176 """Register a new user with 'email' and 'password'."""
176 logger.debug('register_user: email: %r password: <hidden>, '177 logger.debug('register_with_name: email: %r password: <hidden>, '
177 'captcha_id: %r, captcha_solution: %r',178 'displayname: %r, captcha_id: %r, captcha_solution: %r',
178 email, captcha_id, captcha_solution)179 email, displayname, captcha_id, captcha_solution)
179 sso_service = self.sso_service_class(None, self.service_url)180 sso_service = self.sso_service_class(None, self.service_url)
180 if not self._valid_email(email):181 if not self._valid_email(email):
181 logger.error('register_user: InvalidEmailError for email: %r',182 logger.error('register_with_name: InvalidEmailError for email: %r',
182 email)183 email)
183 raise InvalidEmailError()184 raise InvalidEmailError()
184 if not self._valid_password(password):185 if not self._valid_password(password):
185 logger.error('register_user: InvalidPasswordError')186 logger.error('register_with_name: InvalidPasswordError')
186 raise InvalidPasswordError()187 raise InvalidPasswordError()
187188
188 result = sso_service.registrations.register(189 result = sso_service.registrations.register(
189 email=email, password=password, captcha_id=captcha_id,190 email=email, password=password,
191 displayname=displayname,
192 captcha_id=captcha_id,
190 captcha_solution=captcha_solution)193 captcha_solution=captcha_solution)
191 logger.info('register_user: email: %r result: %r', email, result)194 logger.info('register_with_name: email: %r result: %r', email, result)
192195
193 if result['status'] == 'error':196 if result['status'] == 'error':
194 errorsdict = self._format_webservice_errors(result['errors'])197 errorsdict = self._format_webservice_errors(result['errors'])
@@ -198,6 +201,17 @@
198 else:201 else:
199 return email202 return email
200203
204 def register_user(self, email, password,
205 captcha_id, captcha_solution):
206 """Register a new user with 'email' and 'password'."""
207 logger.debug('register_user: email: %r password: <hidden>, '
208 'captcha_id: %r, captcha_solution: %r',
209 email, captcha_id, captcha_solution)
210 res = self.register_with_name(email, password, displayname='',
211 captcha_id=captcha_id,
212 captcha_solution=captcha_solution)
213 return res
214
201 def login(self, email, password, token_name):215 def login(self, email, password, token_name):
202 """Login a user with 'email' and 'password'."""216 """Login a user with 'email' and 'password'."""
203 logger.debug('login: email: %r password: <hidden>, token_name: %r',217 logger.debug('login: email: %r password: <hidden>, token_name: %r',
@@ -387,6 +401,17 @@
387 captcha_id, captcha_solution)401 captcha_id, captcha_solution)
388 blocking(f, app_name, self.UserRegistered, self.UserRegistrationError)402 blocking(f, app_name, self.UserRegistered, self.UserRegistrationError)
389403
404 @dbus.service.method(dbus_interface=DBUS_IFACE_USER_NAME,
405 in_signature='ssssss')
406 def register_with_name(self, app_name, email, password, name,
407 captcha_id, captcha_solution):
408 """Call the matching method in the processor."""
409 def f():
410 """Inner function that will be run in a thread."""
411 return self.processor.register_with_name(email, password, name,
412 captcha_id, captcha_solution)
413 blocking(f, app_name, self.UserRegistered, self.UserRegistrationError)
414
390 # login signals415 # login signals
391 @dbus.service.signal(DBUS_IFACE_USER_NAME, signature="ss")416 @dbus.service.signal(DBUS_IFACE_USER_NAME, signature="ss")
392 def LoggedIn(self, app_name, result):417 def LoggedIn(self, app_name, result):
393418
=== modified file 'ubuntu_sso/tests/test_gui.py'
--- ubuntu_sso/tests/test_gui.py 2010-11-04 12:20:56 +0000
+++ ubuntu_sso/tests/test_gui.py 2011-04-12 19:05:52 +0000
@@ -63,7 +63,7 @@
63 self._args = args63 self._args = args
64 self._kwargs = kwargs64 self._kwargs = kwargs
65 self._called = {}65 self._called = {}
66 for i in ('generate_captcha', 'login', 'register_user',66 for i in ('generate_captcha', 'login', 'register_with_name',
67 'validate_email', 'request_password_reset_token',67 'validate_email', 'request_password_reset_token',
68 'set_new_password'):68 'set_new_password'):
69 setattr(self, i, self._record_call(i))69 setattr(self, i, self._record_call(i))
@@ -674,11 +674,11 @@
674 """Clicking 'join_ok_button' sends info to backend using 'register'."""674 """Clicking 'join_ok_button' sends info to backend using 'register'."""
675 self.click_join_with_valid_data()675 self.click_join_with_valid_data()
676676
677 # assert register_user was called677 # assert register_with_name was called
678 expected = 'register_user'678 expected = 'register_with_name'
679 self.assertIn(expected, self.ui.backend._called)679 self.assertIn(expected, self.ui.backend._called)
680 self.assertEqual(self.ui.backend._called[expected],680 self.assertEqual(self.ui.backend._called[expected],
681 ((APP_NAME, EMAIL, PASSWORD, CAPTCHA_ID,681 ((APP_NAME, EMAIL, PASSWORD, NAME, CAPTCHA_ID,
682 CAPTCHA_SOLUTION),682 CAPTCHA_SOLUTION),
683 dict(reply_handler=gui.NO_OP,683 dict(reply_handler=gui.NO_OP,
684 error_handler=gui.NO_OP)))684 error_handler=gui.NO_OP)))
@@ -1161,12 +1161,7 @@
11611161
1162 self.assert_correct_entry_warning(self.ui.name_entry,1162 self.assert_correct_entry_warning(self.ui.name_entry,
1163 self.ui.FIELD_REQUIRED)1163 self.ui.FIELD_REQUIRED)
1164 self.assertNotIn('register_user', self.ui.backend._called)1164 self.assertNotIn('register_with_name', self.ui.backend._called)
1165
1166 # Unused variable 'skip'
1167 # pylint: disable=W0612
1168 test_warning_is_shown_if_name_empty.skip = \
1169 'Unused for now, will be hidden to save space (LP: #627440).'
11701165
1171 def test_warning_is_shown_if_empty_email(self):1166 def test_warning_is_shown_if_empty_email(self):
1172 """A warning message is shown if emails are empty."""1167 """A warning message is shown if emails are empty."""
@@ -1179,7 +1174,7 @@
1179 self.ui.FIELD_REQUIRED)1174 self.ui.FIELD_REQUIRED)
1180 self.assert_correct_entry_warning(self.ui.email2_entry,1175 self.assert_correct_entry_warning(self.ui.email2_entry,
1181 self.ui.FIELD_REQUIRED)1176 self.ui.FIELD_REQUIRED)
1182 self.assertNotIn('register_user', self.ui.backend._called)1177 self.assertNotIn('register_with_name', self.ui.backend._called)
11831178
1184 def test_warning_is_shown_if_email_mismatch(self):1179 def test_warning_is_shown_if_email_mismatch(self):
1185 """A warning message is shown if emails doesn't match."""1180 """A warning message is shown if emails doesn't match."""
@@ -1192,7 +1187,7 @@
1192 self.ui.EMAIL_MISMATCH)1187 self.ui.EMAIL_MISMATCH)
1193 self.assert_correct_entry_warning(self.ui.email2_entry,1188 self.assert_correct_entry_warning(self.ui.email2_entry,
1194 self.ui.EMAIL_MISMATCH)1189 self.ui.EMAIL_MISMATCH)
1195 self.assertNotIn('register_user', self.ui.backend._called)1190 self.assertNotIn('register_with_name', self.ui.backend._called)
11961191
1197 def test_warning_is_shown_if_invalid_email(self):1192 def test_warning_is_shown_if_invalid_email(self):
1198 """A warning message is shown if email is invalid."""1193 """A warning message is shown if email is invalid."""
@@ -1205,7 +1200,7 @@
1205 self.ui.EMAIL_INVALID)1200 self.ui.EMAIL_INVALID)
1206 self.assert_correct_entry_warning(self.ui.email2_entry,1201 self.assert_correct_entry_warning(self.ui.email2_entry,
1207 self.ui.EMAIL_INVALID)1202 self.ui.EMAIL_INVALID)
1208 self.assertNotIn('register_user', self.ui.backend._called)1203 self.assertNotIn('register_with_name', self.ui.backend._called)
12091204
1210 def test_password_help_is_always_shown(self):1205 def test_password_help_is_always_shown(self):
1211 """Password help text is correctly displayed."""1206 """Password help text is correctly displayed."""
@@ -1213,7 +1208,7 @@
1213 'password help text is visible.')1208 'password help text is visible.')
1214 self.assertEqual(self.ui.password_help_label.get_text(),1209 self.assertEqual(self.ui.password_help_label.get_text(),
1215 self.ui.PASSWORD_HELP)1210 self.ui.PASSWORD_HELP)
1216 self.assertNotIn('register_user', self.ui.backend._called)1211 self.assertNotIn('register_with_name', self.ui.backend._called)
12171212
1218 def test_warning_is_shown_if_password_mismatch(self):1213 def test_warning_is_shown_if_password_mismatch(self):
1219 """A warning message is shown if password doesn't match."""1214 """A warning message is shown if password doesn't match."""
@@ -1226,7 +1221,7 @@
1226 self.ui.PASSWORD_MISMATCH)1221 self.ui.PASSWORD_MISMATCH)
1227 self.assert_correct_entry_warning(self.ui.password2_entry,1222 self.assert_correct_entry_warning(self.ui.password2_entry,
1228 self.ui.PASSWORD_MISMATCH)1223 self.ui.PASSWORD_MISMATCH)
1229 self.assertNotIn('register_user', self.ui.backend._called)1224 self.assertNotIn('register_with_name', self.ui.backend._called)
12301225
1231 def test_warning_is_shown_if_password_too_weak(self):1226 def test_warning_is_shown_if_password_too_weak(self):
1232 """A warning message is shown if password is too weak."""1227 """A warning message is shown if password is too weak."""
@@ -1241,7 +1236,7 @@
1241 self.ui.PASSWORD_TOO_WEAK)1236 self.ui.PASSWORD_TOO_WEAK)
1242 self.assert_correct_entry_warning(self.ui.password2_entry,1237 self.assert_correct_entry_warning(self.ui.password2_entry,
1243 self.ui.PASSWORD_TOO_WEAK)1238 self.ui.PASSWORD_TOO_WEAK)
1244 self.assertNotIn('register_user', self.ui.backend._called)1239 self.assertNotIn('register_with_name', self.ui.backend._called)
12451240
1246 def test_warning_is_shown_if_tc_not_accepted(self):1241 def test_warning_is_shown_if_tc_not_accepted(self):
1247 """A warning message is shown if TC are not accepted."""1242 """A warning message is shown if TC are not accepted."""
@@ -1252,7 +1247,7 @@
12521247
1253 self.assert_correct_label_warning(self.ui.tc_warning_label,1248 self.assert_correct_label_warning(self.ui.tc_warning_label,
1254 self.ui.TC_NOT_ACCEPTED)1249 self.ui.TC_NOT_ACCEPTED)
1255 self.assertNotIn('register_user', self.ui.backend._called)1250 self.assertNotIn('register_with_name', self.ui.backend._called)
12561251
1257 def test_warning_is_shown_if_not_captcha_solution(self):1252 def test_warning_is_shown_if_not_captcha_solution(self):
1258 """A warning message is shown if TC are not accepted."""1253 """A warning message is shown if TC are not accepted."""
@@ -1263,7 +1258,7 @@
12631258
1264 self.assert_correct_entry_warning(self.ui.captcha_solution_entry,1259 self.assert_correct_entry_warning(self.ui.captcha_solution_entry,
1265 self.ui.FIELD_REQUIRED)1260 self.ui.FIELD_REQUIRED)
1266 self.assertNotIn('register_user', self.ui.backend._called)1261 self.assertNotIn('register_with_name', self.ui.backend._called)
12671262
1268 def test_no_warning_messages_if_valid_data(self):1263 def test_no_warning_messages_if_valid_data(self):
1269 """No warning messages are shown if the data is valid."""1264 """No warning messages are shown if the data is valid."""
12701265
=== modified file 'ubuntu_sso/tests/test_main.py'
--- ubuntu_sso/tests/test_main.py 2010-12-16 13:19:01 +0000
+++ ubuntu_sso/tests/test_main.py 2011-04-12 19:05:52 +0000
@@ -1,3 +1,5 @@
1# -*- coding: utf-8 -*-
2#
1# test_main - tests for ubuntu_sso.main3# test_main - tests for ubuntu_sso.main
2#4#
3# Author: Natalia Bidart <natalia.bidart@canonical.com>5# Author: Natalia Bidart <natalia.bidart@canonical.com>
@@ -63,6 +65,7 @@
63EMAIL_ALREADY_REGISTERED = 'a@example.com'65EMAIL_ALREADY_REGISTERED = 'a@example.com'
64EMAIL_TOKEN = 'B2Pgtf'66EMAIL_TOKEN = 'B2Pgtf'
65HELP = 'help text'67HELP = 'help text'
68NAME = 'Juanito PĂ©rez'
66PASSWORD = 'be4tiFul'69PASSWORD = 'be4tiFul'
67RESET_PASSWORD_TOKEN = '8G5Wtq'70RESET_PASSWORD_TOKEN = '8G5Wtq'
68TOKEN = {u'consumer_key': u'xQ7xDAz',71TOKEN = {u'consumer_key': u'xQ7xDAz',
@@ -107,7 +110,8 @@
107class FakedRegistrations(object):110class FakedRegistrations(object):
108 """Fake the registrations service."""111 """Fake the registrations service."""
109112
110 def register(self, email, password, captcha_id, captcha_solution):113 def register(self, email, password, displayname,
114 captcha_id, captcha_solution):
111 """Fake registration. Return a fix result."""115 """Fake registration. Return a fix result."""
112 if email == EMAIL_ALREADY_REGISTERED:116 if email == EMAIL_ALREADY_REGISTERED:
113 return {'status': 'error',117 return {'status': 'error',
@@ -399,6 +403,16 @@
399 self.assertIn('Received invalid reply: %s' % STATUS_UNKNOWN, exc)403 self.assertIn('Received invalid reply: %s' % STATUS_UNKNOWN, exc)
400404
401405
406class SSORegistrationWithNameTestCase(SSOLoginProcessorTestCase):
407 """Test suite for the SSO login processor for register_with_name."""
408
409 def setUp(self):
410 """Init."""
411 super(SSORegistrationWithNameTestCase, self).setUp()
412 self.register_kwargs['displayname'] = NAME
413 self.processor.register_user = self.processor.register_with_name
414
415
402class BlockingSampleException(Exception):416class BlockingSampleException(Exception):
403 """The exception that will be thrown by the fake blocking."""417 """The exception that will be thrown by the fake blocking."""
404418
@@ -510,8 +524,8 @@
510 """Test that the register_user method works ok."""524 """Test that the register_user method works ok."""
511 d = Deferred()525 d = Deferred()
512 expected_result = "expected result"526 expected_result = "expected result"
513 self.create_mock_processor().register_user(EMAIL, PASSWORD, CAPTCHA_ID,527 self.create_mock_processor().register_user(EMAIL, PASSWORD,
514 CAPTCHA_SOLUTION)528 CAPTCHA_ID, CAPTCHA_SOLUTION)
515 self.mocker.result(expected_result)529 self.mocker.result(expected_result)
516 self.patch(ubuntu_sso.main, "blocking", self.fake_ok_blocking)530 self.patch(ubuntu_sso.main, "blocking", self.fake_ok_blocking)
517 self.mocker.replay()531 self.mocker.replay()
@@ -534,8 +548,8 @@
534 """Test that the register_user method fails as expected."""548 """Test that the register_user method fails as expected."""
535 d = Deferred()549 d = Deferred()
536 expected_result = "expected result"550 expected_result = "expected result"
537 self.create_mock_processor().register_user(EMAIL, PASSWORD, CAPTCHA_ID,551 self.create_mock_processor().register_user(EMAIL, PASSWORD,
538 CAPTCHA_SOLUTION)552 CAPTCHA_ID, CAPTCHA_SOLUTION)
539 self.mocker.result(expected_result)553 self.mocker.result(expected_result)
540 self.patch(ubuntu_sso.main, "blocking", self.fake_err_blocking)554 self.patch(ubuntu_sso.main, "blocking", self.fake_err_blocking)
541 self.mocker.replay()555 self.mocker.replay()
@@ -554,6 +568,54 @@
554 CAPTCHA_SOLUTION)568 CAPTCHA_SOLUTION)
555 return d569 return d
556570
571 def test_register_with_name(self):
572 """Test that the register_with_name method works ok."""
573 d = Deferred()
574 expected_result = "expected result"
575 self.create_mock_processor().register_with_name(EMAIL, PASSWORD, NAME,
576 CAPTCHA_ID, CAPTCHA_SOLUTION)
577 self.mocker.result(expected_result)
578 self.patch(ubuntu_sso.main, "blocking", self.fake_ok_blocking)
579 self.mocker.replay()
580
581 def verify(app_name, result):
582 """The actual test."""
583 self.assertEqual(result, expected_result)
584 self.assertEqual(app_name, APP_NAME)
585 d.callback(result)
586
587 client = SSOLogin(self.mockbusname,
588 sso_login_processor_class=self.mockprocessorclass)
589 self.patch(client, "UserRegistered", verify)
590 self.patch(client, "UserRegistrationError", d.errback)
591 client.register_with_name(APP_NAME, EMAIL, PASSWORD, NAME, CAPTCHA_ID,
592 CAPTCHA_SOLUTION)
593 return d
594
595 def test_register_with_name_error(self):
596 """Test that the register_with_name method fails as expected."""
597 d = Deferred()
598 expected_result = "expected result"
599 self.create_mock_processor().register_with_name(EMAIL, PASSWORD, NAME,
600 CAPTCHA_ID, CAPTCHA_SOLUTION)
601 self.mocker.result(expected_result)
602 self.patch(ubuntu_sso.main, "blocking", self.fake_err_blocking)
603 self.mocker.replay()
604
605 def verify(app_name, errdict):
606 """The actual test."""
607 self.assertEqual(errdict["errtype"], "BlockingSampleException")
608 self.assertEqual(app_name, APP_NAME)
609 d.callback("Ok")
610
611 client = SSOLogin(self.mockbusname,
612 sso_login_processor_class=self.mockprocessorclass)
613 self.patch(client, "UserRegistered", d.errback)
614 self.patch(client, "UserRegistrationError", verify)
615 client.register_with_name(APP_NAME, EMAIL, PASSWORD, NAME, CAPTCHA_ID,
616 CAPTCHA_SOLUTION)
617 return d
618
557 def test_login(self):619 def test_login(self):
558 """Test that the login method works ok."""620 """Test that the login method works ok."""
559 d = Deferred()621 d = Deferred()

Subscribers

People subscribed via source and target branches