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

Proposed by Natalia Bidart
Status: Merged
Approved by: Natalia Bidart
Approved revision: 680
Merged at revision: 682
Proposed branch: lp:~nataliabidart/ubuntu-sso-client/displayname
Merge into: lp:ubuntu-sso-client
Diff against target: 242 lines (+35/-36)
8 files modified
ubuntu_sso/account.py (+7/-4)
ubuntu_sso/gtk/gui.py (+8/-10)
ubuntu_sso/gtk/tests/test_gui.py (+1/-6)
ubuntu_sso/main/__init__.py (+2/-2)
ubuntu_sso/main/linux.py (+3/-3)
ubuntu_sso/tests/main/test_common.py (+3/-2)
ubuntu_sso/tests/main/test_linux.py (+7/-7)
ubuntu_sso/tests/test_account.py (+4/-2)
To merge this branch: bzr merge lp:~nataliabidart/ubuntu-sso-client/displayname
Reviewer Review Type Date Requested Status
Eric Casteleijn (community) Approve
Martin Albisetti (community) Approve
Review via email: mp+54216@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 test, run in this branch:

DEBUG=True PYTHONPATH=. ./bin/ubuntu-sso-login

From d-feet, run the 'register' method for the /com/ubuntu/sso/credentials DBus interface. Pass parameters like these:

'A testing App', {}

and once you're properly registered, check on https://login.ubuntu.com/ that your display name was properly set.

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

Tests pass, code looks good, and manual testing shows it works.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'ubuntu_sso/account.py'
--- ubuntu_sso/account.py 2010-12-15 20:42:15 +0000
+++ ubuntu_sso/account.py 2011-03-21 14:44:25 +0000
@@ -127,11 +127,12 @@
127127
128 return captcha['captcha_id']128 return captcha['captcha_id']
129129
130 def register_user(self, email, password, captcha_id, captcha_solution):130 def register_user(self, email, password, displayname,
131 captcha_id, captcha_solution):
131 """Register a new user with 'email' and 'password'."""132 """Register a new user with 'email' and 'password'."""
132 logger.debug('register_user: email: %r password: <hidden>, '133 logger.debug('register_user: email: %r password: <hidden>, '
133 'captcha_id: %r, captcha_solution: %r',134 'displayname: %r, captcha_id: %r, captcha_solution: %r',
134 email, captcha_id, captcha_solution)135 email, displayname, captcha_id, captcha_solution)
135 sso_service = self.sso_service_class(None, self.service_url)136 sso_service = self.sso_service_class(None, self.service_url)
136 if not self._valid_email(email):137 if not self._valid_email(email):
137 logger.error('register_user: InvalidEmailError for email: %r',138 logger.error('register_user: InvalidEmailError for email: %r',
@@ -142,7 +143,9 @@
142 raise InvalidPasswordError()143 raise InvalidPasswordError()
143144
144 result = sso_service.registrations.register(145 result = sso_service.registrations.register(
145 email=email, password=password, captcha_id=captcha_id,146 email=email, password=password,
147 displayname=displayname,
148 captcha_id=captcha_id,
146 captcha_solution=captcha_solution)149 captcha_solution=captcha_solution)
147 logger.info('register_user: email: %r result: %r', email, result)150 logger.info('register_user: email: %r result: %r', email, result)
148151
149152
=== modified file 'ubuntu_sso/gtk/gui.py'
--- ubuntu_sso/gtk/gui.py 2011-01-02 03:27:34 +0000
+++ ubuntu_sso/gtk/gui.py 2011-03-21 14:44:25 +0000
@@ -371,8 +371,6 @@
371 msg = 'UbuntuSSOClientGUI: failed set_transient_for win id %r'371 msg = 'UbuntuSSOClientGUI: failed set_transient_for win id %r'
372 logger.exception(msg, window_id)372 logger.exception(msg, window_id)
373373
374 # Hidding unused widgets to save some space (LP #627440).
375 self.name_entry.hide()
376 self.yes_to_updates_checkbutton.hide()374 self.yes_to_updates_checkbutton.hide()
377375
378 self.window.show()376 self.window.show()
@@ -777,11 +775,10 @@
777775
778 error = False776 error = False
779777
780 # Hidding unused widgets to save some space (LP #627440).778 name = self.name_entry.get_text()
781 #name = self.name_entry.get_text()779 if not name:
782 #if not name:780 self.name_entry.set_warning(self.FIELD_REQUIRED)
783 # self.name_entry.set_warning(self.FIELD_REQUIRED)781 error = True
784 # error = True
785782
786 # check email783 # check email
787 email1 = self.email1_entry.get_text()784 email1 = self.email1_entry.get_text()
@@ -820,10 +817,11 @@
820 self.user_password = password1817 self.user_password = password1
821818
822 logger.info('Calling register_user with email %r, password <hidden>,' \819 logger.info('Calling register_user with email %r, password <hidden>,' \
823 ' captcha_id %r and captcha_solution %r.', email1,820 ' name %r, captcha_id %r and captcha_solution %r.', email1,
824 self._captcha_id, captcha_solution)821 name, self._captcha_id, captcha_solution)
825 f = self.backend.register_user822 f = self.backend.register_user
826 f(self.app_name, email1, password1, self._captcha_id, captcha_solution,823 f(self.app_name, email1, password1, name,
824 self._captcha_id, captcha_solution,
827 reply_handler=NO_OP, error_handler=NO_OP)825 reply_handler=NO_OP, error_handler=NO_OP)
828826
829 def on_verify_token_button_clicked(self, *args, **kwargs):827 def on_verify_token_button_clicked(self, *args, **kwargs):
830828
=== modified file 'ubuntu_sso/gtk/tests/test_gui.py'
--- ubuntu_sso/gtk/tests/test_gui.py 2011-01-02 03:27:34 +0000
+++ ubuntu_sso/gtk/tests/test_gui.py 2011-03-21 14:44:25 +0000
@@ -713,7 +713,7 @@
713 expected = 'register_user'713 expected = 'register_user'
714 self.assertIn(expected, self.ui.backend._called)714 self.assertIn(expected, self.ui.backend._called)
715 self.assertEqual(self.ui.backend._called[expected],715 self.assertEqual(self.ui.backend._called[expected],
716 ((APP_NAME, EMAIL, PASSWORD, CAPTCHA_ID,716 ((APP_NAME, EMAIL, PASSWORD, NAME, CAPTCHA_ID,
717 CAPTCHA_SOLUTION),717 CAPTCHA_SOLUTION),
718 dict(reply_handler=gui.NO_OP,718 dict(reply_handler=gui.NO_OP,
719 error_handler=gui.NO_OP)))719 error_handler=gui.NO_OP)))
@@ -1314,11 +1314,6 @@
1314 self.ui.FIELD_REQUIRED)1314 self.ui.FIELD_REQUIRED)
1315 self.assertNotIn('register_user', self.ui.backend._called)1315 self.assertNotIn('register_user', self.ui.backend._called)
13161316
1317 # Unused variable 'skip'
1318 # pylint: disable=W0612
1319 test_warning_is_shown_if_name_empty.skip = \
1320 'Unused for now, will be hidden to save space (LP: #627440).'
1321
1322 def test_warning_is_shown_if_empty_email(self):1317 def test_warning_is_shown_if_empty_email(self):
1323 """A warning message is shown if emails are empty."""1318 """A warning message is shown if emails are empty."""
1324 self.ui.email1_entry.set_text('')1319 self.ui.email1_entry.set_text('')
13251320
=== modified file 'ubuntu_sso/main/__init__.py'
--- ubuntu_sso/main/__init__.py 2011-03-16 04:59:16 +0000
+++ ubuntu_sso/main/__init__.py 2011-03-21 14:44:25 +0000
@@ -82,12 +82,12 @@
82 return self.processor.generate_captcha(filename)82 return self.processor.generate_captcha(filename)
83 thread_execute(f, app_name, result_cb, error_cb)83 thread_execute(f, app_name, result_cb, error_cb)
8484
85 def register_user(self, app_name, email, password, captcha_id,85 def register_user(self, app_name, email, password, name, captcha_id,
86 captcha_solution, thread_execute, result_cb, error_cb):86 captcha_solution, thread_execute, result_cb, error_cb):
87 """Call the matching method in the processor."""87 """Call the matching method in the processor."""
88 def f():88 def f():
89 """Inner function that will be run in a thread."""89 """Inner function that will be run in a thread."""
90 return self.processor.register_user(email, password,90 return self.processor.register_user(email, password, name,
91 captcha_id, captcha_solution)91 captcha_id, captcha_solution)
92 thread_execute(f, app_name, result_cb, error_cb)92 thread_execute(f, app_name, result_cb, error_cb)
9393
9494
=== modified file 'ubuntu_sso/main/linux.py'
--- ubuntu_sso/main/linux.py 2011-02-24 13:06:07 +0000
+++ ubuntu_sso/main/linux.py 2011-03-21 14:44:25 +0000
@@ -110,11 +110,11 @@
110 'app_name "%s" and error %r', app_name, error)110 'app_name "%s" and error %r', app_name, error)
111111
112 @dbus.service.method(dbus_interface=DBUS_IFACE_USER_NAME,112 @dbus.service.method(dbus_interface=DBUS_IFACE_USER_NAME,
113 in_signature='sssss')113 in_signature='ssssss')
114 def register_user(self, app_name, email, password,114 def register_user(self, app_name, email, password, name,
115 captcha_id, captcha_solution):115 captcha_id, captcha_solution):
116 """Call the matching method in the processor."""116 """Call the matching method in the processor."""
117 self.root.register_user(app_name, email, password, captcha_id,117 self.root.register_user(app_name, email, password, name, captcha_id,
118 captcha_solution, blocking,118 captcha_solution, blocking,
119 self.UserRegistered,119 self.UserRegistered,
120 self.UserRegistrationError)120 self.UserRegistrationError)
121121
=== modified file 'ubuntu_sso/tests/main/test_common.py'
--- ubuntu_sso/tests/main/test_common.py 2011-03-16 04:59:16 +0000
+++ ubuntu_sso/tests/main/test_common.py 2011-03-21 14:44:25 +0000
@@ -85,13 +85,14 @@
85 app_name = 'app'85 app_name = 'app'
86 email = 'email'86 email = 'email'
87 password = 'pwd'87 password = 'pwd'
88 name = 'display name'
88 captcha_id = 'id'89 captcha_id = 'id'
89 captcha_solution = 'hello'90 captcha_solution = 'hello'
90 self.root.register_user(app_name, email, password, captcha_id,91 self.root.register_user(app_name, email, password, name, captcha_id,
91 captcha_solution, MATCH(callable),92 captcha_solution, MATCH(callable),
92 MATCH(callable), MATCH(callable))93 MATCH(callable), MATCH(callable))
93 self.mocker.replay()94 self.mocker.replay()
94 self.login.register_user(app_name, email, password, captcha_id,95 self.login.register_user(app_name, email, password, name, captcha_id,
95 captcha_solution)96 captcha_solution)
9697
97 def test_login(self):98 def test_login(self):
9899
=== modified file 'ubuntu_sso/tests/main/test_linux.py'
--- ubuntu_sso/tests/main/test_linux.py 2011-02-24 13:06:07 +0000
+++ ubuntu_sso/tests/main/test_linux.py 2011-03-21 14:44:25 +0000
@@ -42,7 +42,7 @@
42 TC_URL_KEY, UI_CLASS_KEY, UI_MODULE_KEY, WINDOW_ID_KEY,42 TC_URL_KEY, UI_CLASS_KEY, UI_MODULE_KEY, WINDOW_ID_KEY,
43 SUCCESS_CB_KEY, ERROR_CB_KEY, DENIAL_CB_KEY)43 SUCCESS_CB_KEY, ERROR_CB_KEY, DENIAL_CB_KEY)
44from ubuntu_sso.tests import (APP_NAME, TC_URL, HELP_TEXT, CAPTCHA_ID,44from ubuntu_sso.tests import (APP_NAME, TC_URL, HELP_TEXT, CAPTCHA_ID,
45 CAPTCHA_SOLUTION, EMAIL, EMAIL_TOKEN, PASSWORD, PING_URL, TOKEN,45 CAPTCHA_SOLUTION, EMAIL, EMAIL_TOKEN, NAME, PASSWORD, PING_URL, TOKEN,
46 TOKEN_NAME, WINDOW_ID, TestCase)46 TOKEN_NAME, WINDOW_ID, TestCase)
4747
4848
@@ -164,8 +164,8 @@
164 """Test that the register_user method works ok."""164 """Test that the register_user method works ok."""
165 d = Deferred()165 d = Deferred()
166 expected_result = "expected result"166 expected_result = "expected result"
167 self.create_mock_processor().register_user(EMAIL, PASSWORD, CAPTCHA_ID,167 self.create_mock_processor().register_user(EMAIL, PASSWORD, NAME,
168 CAPTCHA_SOLUTION)168 CAPTCHA_ID, CAPTCHA_SOLUTION)
169 self.mocker.result(expected_result)169 self.mocker.result(expected_result)
170 self.patch(ubuntu_sso.main.linux, "blocking", fake_ok_blocking)170 self.patch(ubuntu_sso.main.linux, "blocking", fake_ok_blocking)
171 self.mocker.replay()171 self.mocker.replay()
@@ -180,7 +180,7 @@
180 sso_login_processor_class=self.mockprocessorclass)180 sso_login_processor_class=self.mockprocessorclass)
181 self.patch(client, "UserRegistered", verify)181 self.patch(client, "UserRegistered", verify)
182 self.patch(client, "UserRegistrationError", d.errback)182 self.patch(client, "UserRegistrationError", d.errback)
183 client.register_user(APP_NAME, EMAIL, PASSWORD, CAPTCHA_ID,183 client.register_user(APP_NAME, EMAIL, PASSWORD, NAME, CAPTCHA_ID,
184 CAPTCHA_SOLUTION)184 CAPTCHA_SOLUTION)
185 return d185 return d
186186
@@ -188,8 +188,8 @@
188 """Test that the register_user method fails as expected."""188 """Test that the register_user method fails as expected."""
189 d = Deferred()189 d = Deferred()
190 expected_result = "expected result"190 expected_result = "expected result"
191 self.create_mock_processor().register_user(EMAIL, PASSWORD, CAPTCHA_ID,191 self.create_mock_processor().register_user(EMAIL, PASSWORD, NAME,
192 CAPTCHA_SOLUTION)192 CAPTCHA_ID, CAPTCHA_SOLUTION)
193 self.mocker.result(expected_result)193 self.mocker.result(expected_result)
194 self.patch(ubuntu_sso.main.linux, "blocking", fake_err_blocking)194 self.patch(ubuntu_sso.main.linux, "blocking", fake_err_blocking)
195 self.mocker.replay()195 self.mocker.replay()
@@ -204,7 +204,7 @@
204 sso_login_processor_class=self.mockprocessorclass)204 sso_login_processor_class=self.mockprocessorclass)
205 self.patch(client, "UserRegistered", d.errback)205 self.patch(client, "UserRegistered", d.errback)
206 self.patch(client, "UserRegistrationError", verify)206 self.patch(client, "UserRegistrationError", verify)
207 client.register_user(APP_NAME, EMAIL, PASSWORD, CAPTCHA_ID,207 client.register_user(APP_NAME, EMAIL, PASSWORD, NAME, CAPTCHA_ID,
208 CAPTCHA_SOLUTION)208 CAPTCHA_SOLUTION)
209 return d209 return d
210210
211211
=== modified file 'ubuntu_sso/tests/test_account.py'
--- ubuntu_sso/tests/test_account.py 2010-12-15 20:42:15 +0000
+++ ubuntu_sso/tests/test_account.py 2011-03-21 14:44:25 +0000
@@ -30,7 +30,7 @@
30 RegistrationError, ResetPasswordTokenError,30 RegistrationError, ResetPasswordTokenError,
31 SSO_STATUS_OK, SSO_STATUS_ERROR)31 SSO_STATUS_OK, SSO_STATUS_ERROR)
32from ubuntu_sso.tests import (APP_NAME, CAPTCHA_ID, CAPTCHA_PATH,32from ubuntu_sso.tests import (APP_NAME, CAPTCHA_ID, CAPTCHA_PATH,
33 CAPTCHA_SOLUTION, EMAIL, EMAIL_TOKEN, PASSWORD, RESET_PASSWORD_TOKEN,33 CAPTCHA_SOLUTION, EMAIL, EMAIL_TOKEN, NAME, PASSWORD, RESET_PASSWORD_TOKEN,
34 TOKEN, TOKEN_NAME)34 TOKEN, TOKEN_NAME)
3535
3636
@@ -59,7 +59,8 @@
59class FakedRegistrations(object):59class FakedRegistrations(object):
60 """Fake the registrations service."""60 """Fake the registrations service."""
6161
62 def register(self, email, password, captcha_id, captcha_solution):62 def register(self, email, password, displayname,
63 captcha_id, captcha_solution):
63 """Fake registration. Return a fix result."""64 """Fake registration. Return a fix result."""
64 if email == EMAIL_ALREADY_REGISTERED:65 if email == EMAIL_ALREADY_REGISTERED:
65 return {'status': SSO_STATUS_ERROR,66 return {'status': SSO_STATUS_ERROR,
@@ -148,6 +149,7 @@
148 """Init."""149 """Init."""
149 self.processor = Account(sso_service_class=FakedSSOServer)150 self.processor = Account(sso_service_class=FakedSSOServer)
150 self.register_kwargs = dict(email=EMAIL, password=PASSWORD,151 self.register_kwargs = dict(email=EMAIL, password=PASSWORD,
152 displayname=NAME,
151 captcha_id=CAPTCHA_ID,153 captcha_id=CAPTCHA_ID,
152 captcha_solution=CAPTCHA_SOLUTION)154 captcha_solution=CAPTCHA_SOLUTION)
153 self.login_kwargs = dict(email=EMAIL, password=PASSWORD,155 self.login_kwargs = dict(email=EMAIL, password=PASSWORD,

Subscribers

People subscribed via source and target branches