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

Proposed by Natalia Bidart on 2011-03-21
Status: Merged
Approved by: Natalia Bidart on 2011-03-21
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 on 2011-03-21
Martin Albisetti (community) 2011-03-21 Approve on 2011-03-21
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.
Martin Albisetti (beuno) :
review: Approve
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
1=== modified file 'ubuntu_sso/account.py'
2--- ubuntu_sso/account.py 2010-12-15 20:42:15 +0000
3+++ ubuntu_sso/account.py 2011-03-21 14:44:25 +0000
4@@ -127,11 +127,12 @@
5
6 return captcha['captcha_id']
7
8- def register_user(self, email, password, captcha_id, captcha_solution):
9+ def register_user(self, email, password, displayname,
10+ captcha_id, captcha_solution):
11 """Register a new user with 'email' and 'password'."""
12 logger.debug('register_user: email: %r password: <hidden>, '
13- 'captcha_id: %r, captcha_solution: %r',
14- email, captcha_id, captcha_solution)
15+ 'displayname: %r, captcha_id: %r, captcha_solution: %r',
16+ email, displayname, captcha_id, captcha_solution)
17 sso_service = self.sso_service_class(None, self.service_url)
18 if not self._valid_email(email):
19 logger.error('register_user: InvalidEmailError for email: %r',
20@@ -142,7 +143,9 @@
21 raise InvalidPasswordError()
22
23 result = sso_service.registrations.register(
24- email=email, password=password, captcha_id=captcha_id,
25+ email=email, password=password,
26+ displayname=displayname,
27+ captcha_id=captcha_id,
28 captcha_solution=captcha_solution)
29 logger.info('register_user: email: %r result: %r', email, result)
30
31
32=== modified file 'ubuntu_sso/gtk/gui.py'
33--- ubuntu_sso/gtk/gui.py 2011-01-02 03:27:34 +0000
34+++ ubuntu_sso/gtk/gui.py 2011-03-21 14:44:25 +0000
35@@ -371,8 +371,6 @@
36 msg = 'UbuntuSSOClientGUI: failed set_transient_for win id %r'
37 logger.exception(msg, window_id)
38
39- # Hidding unused widgets to save some space (LP #627440).
40- self.name_entry.hide()
41 self.yes_to_updates_checkbutton.hide()
42
43 self.window.show()
44@@ -777,11 +775,10 @@
45
46 error = False
47
48- # Hidding unused widgets to save some space (LP #627440).
49- #name = self.name_entry.get_text()
50- #if not name:
51- # self.name_entry.set_warning(self.FIELD_REQUIRED)
52- # error = True
53+ name = self.name_entry.get_text()
54+ if not name:
55+ self.name_entry.set_warning(self.FIELD_REQUIRED)
56+ error = True
57
58 # check email
59 email1 = self.email1_entry.get_text()
60@@ -820,10 +817,11 @@
61 self.user_password = password1
62
63 logger.info('Calling register_user with email %r, password <hidden>,' \
64- ' captcha_id %r and captcha_solution %r.', email1,
65- self._captcha_id, captcha_solution)
66+ ' name %r, captcha_id %r and captcha_solution %r.', email1,
67+ name, self._captcha_id, captcha_solution)
68 f = self.backend.register_user
69- f(self.app_name, email1, password1, self._captcha_id, captcha_solution,
70+ f(self.app_name, email1, password1, name,
71+ self._captcha_id, captcha_solution,
72 reply_handler=NO_OP, error_handler=NO_OP)
73
74 def on_verify_token_button_clicked(self, *args, **kwargs):
75
76=== modified file 'ubuntu_sso/gtk/tests/test_gui.py'
77--- ubuntu_sso/gtk/tests/test_gui.py 2011-01-02 03:27:34 +0000
78+++ ubuntu_sso/gtk/tests/test_gui.py 2011-03-21 14:44:25 +0000
79@@ -713,7 +713,7 @@
80 expected = 'register_user'
81 self.assertIn(expected, self.ui.backend._called)
82 self.assertEqual(self.ui.backend._called[expected],
83- ((APP_NAME, EMAIL, PASSWORD, CAPTCHA_ID,
84+ ((APP_NAME, EMAIL, PASSWORD, NAME, CAPTCHA_ID,
85 CAPTCHA_SOLUTION),
86 dict(reply_handler=gui.NO_OP,
87 error_handler=gui.NO_OP)))
88@@ -1314,11 +1314,6 @@
89 self.ui.FIELD_REQUIRED)
90 self.assertNotIn('register_user', self.ui.backend._called)
91
92- # Unused variable 'skip'
93- # pylint: disable=W0612
94- test_warning_is_shown_if_name_empty.skip = \
95- 'Unused for now, will be hidden to save space (LP: #627440).'
96-
97 def test_warning_is_shown_if_empty_email(self):
98 """A warning message is shown if emails are empty."""
99 self.ui.email1_entry.set_text('')
100
101=== modified file 'ubuntu_sso/main/__init__.py'
102--- ubuntu_sso/main/__init__.py 2011-03-16 04:59:16 +0000
103+++ ubuntu_sso/main/__init__.py 2011-03-21 14:44:25 +0000
104@@ -82,12 +82,12 @@
105 return self.processor.generate_captcha(filename)
106 thread_execute(f, app_name, result_cb, error_cb)
107
108- def register_user(self, app_name, email, password, captcha_id,
109+ def register_user(self, app_name, email, password, name, captcha_id,
110 captcha_solution, thread_execute, result_cb, error_cb):
111 """Call the matching method in the processor."""
112 def f():
113 """Inner function that will be run in a thread."""
114- return self.processor.register_user(email, password,
115+ return self.processor.register_user(email, password, name,
116 captcha_id, captcha_solution)
117 thread_execute(f, app_name, result_cb, error_cb)
118
119
120=== modified file 'ubuntu_sso/main/linux.py'
121--- ubuntu_sso/main/linux.py 2011-02-24 13:06:07 +0000
122+++ ubuntu_sso/main/linux.py 2011-03-21 14:44:25 +0000
123@@ -110,11 +110,11 @@
124 'app_name "%s" and error %r', app_name, error)
125
126 @dbus.service.method(dbus_interface=DBUS_IFACE_USER_NAME,
127- in_signature='sssss')
128- def register_user(self, app_name, email, password,
129+ in_signature='ssssss')
130+ def register_user(self, app_name, email, password, name,
131 captcha_id, captcha_solution):
132 """Call the matching method in the processor."""
133- self.root.register_user(app_name, email, password, captcha_id,
134+ self.root.register_user(app_name, email, password, name, captcha_id,
135 captcha_solution, blocking,
136 self.UserRegistered,
137 self.UserRegistrationError)
138
139=== modified file 'ubuntu_sso/tests/main/test_common.py'
140--- ubuntu_sso/tests/main/test_common.py 2011-03-16 04:59:16 +0000
141+++ ubuntu_sso/tests/main/test_common.py 2011-03-21 14:44:25 +0000
142@@ -85,13 +85,14 @@
143 app_name = 'app'
144 email = 'email'
145 password = 'pwd'
146+ name = 'display name'
147 captcha_id = 'id'
148 captcha_solution = 'hello'
149- self.root.register_user(app_name, email, password, captcha_id,
150+ self.root.register_user(app_name, email, password, name, captcha_id,
151 captcha_solution, MATCH(callable),
152 MATCH(callable), MATCH(callable))
153 self.mocker.replay()
154- self.login.register_user(app_name, email, password, captcha_id,
155+ self.login.register_user(app_name, email, password, name, captcha_id,
156 captcha_solution)
157
158 def test_login(self):
159
160=== modified file 'ubuntu_sso/tests/main/test_linux.py'
161--- ubuntu_sso/tests/main/test_linux.py 2011-02-24 13:06:07 +0000
162+++ ubuntu_sso/tests/main/test_linux.py 2011-03-21 14:44:25 +0000
163@@ -42,7 +42,7 @@
164 TC_URL_KEY, UI_CLASS_KEY, UI_MODULE_KEY, WINDOW_ID_KEY,
165 SUCCESS_CB_KEY, ERROR_CB_KEY, DENIAL_CB_KEY)
166 from ubuntu_sso.tests import (APP_NAME, TC_URL, HELP_TEXT, CAPTCHA_ID,
167- CAPTCHA_SOLUTION, EMAIL, EMAIL_TOKEN, PASSWORD, PING_URL, TOKEN,
168+ CAPTCHA_SOLUTION, EMAIL, EMAIL_TOKEN, NAME, PASSWORD, PING_URL, TOKEN,
169 TOKEN_NAME, WINDOW_ID, TestCase)
170
171
172@@ -164,8 +164,8 @@
173 """Test that the register_user method works ok."""
174 d = Deferred()
175 expected_result = "expected result"
176- self.create_mock_processor().register_user(EMAIL, PASSWORD, CAPTCHA_ID,
177- CAPTCHA_SOLUTION)
178+ self.create_mock_processor().register_user(EMAIL, PASSWORD, NAME,
179+ CAPTCHA_ID, CAPTCHA_SOLUTION)
180 self.mocker.result(expected_result)
181 self.patch(ubuntu_sso.main.linux, "blocking", fake_ok_blocking)
182 self.mocker.replay()
183@@ -180,7 +180,7 @@
184 sso_login_processor_class=self.mockprocessorclass)
185 self.patch(client, "UserRegistered", verify)
186 self.patch(client, "UserRegistrationError", d.errback)
187- client.register_user(APP_NAME, EMAIL, PASSWORD, CAPTCHA_ID,
188+ client.register_user(APP_NAME, EMAIL, PASSWORD, NAME, CAPTCHA_ID,
189 CAPTCHA_SOLUTION)
190 return d
191
192@@ -188,8 +188,8 @@
193 """Test that the register_user method fails as expected."""
194 d = Deferred()
195 expected_result = "expected result"
196- self.create_mock_processor().register_user(EMAIL, PASSWORD, CAPTCHA_ID,
197- CAPTCHA_SOLUTION)
198+ self.create_mock_processor().register_user(EMAIL, PASSWORD, NAME,
199+ CAPTCHA_ID, CAPTCHA_SOLUTION)
200 self.mocker.result(expected_result)
201 self.patch(ubuntu_sso.main.linux, "blocking", fake_err_blocking)
202 self.mocker.replay()
203@@ -204,7 +204,7 @@
204 sso_login_processor_class=self.mockprocessorclass)
205 self.patch(client, "UserRegistered", d.errback)
206 self.patch(client, "UserRegistrationError", verify)
207- client.register_user(APP_NAME, EMAIL, PASSWORD, CAPTCHA_ID,
208+ client.register_user(APP_NAME, EMAIL, PASSWORD, NAME, CAPTCHA_ID,
209 CAPTCHA_SOLUTION)
210 return d
211
212
213=== modified file 'ubuntu_sso/tests/test_account.py'
214--- ubuntu_sso/tests/test_account.py 2010-12-15 20:42:15 +0000
215+++ ubuntu_sso/tests/test_account.py 2011-03-21 14:44:25 +0000
216@@ -30,7 +30,7 @@
217 RegistrationError, ResetPasswordTokenError,
218 SSO_STATUS_OK, SSO_STATUS_ERROR)
219 from ubuntu_sso.tests import (APP_NAME, CAPTCHA_ID, CAPTCHA_PATH,
220- CAPTCHA_SOLUTION, EMAIL, EMAIL_TOKEN, PASSWORD, RESET_PASSWORD_TOKEN,
221+ CAPTCHA_SOLUTION, EMAIL, EMAIL_TOKEN, NAME, PASSWORD, RESET_PASSWORD_TOKEN,
222 TOKEN, TOKEN_NAME)
223
224
225@@ -59,7 +59,8 @@
226 class FakedRegistrations(object):
227 """Fake the registrations service."""
228
229- def register(self, email, password, captcha_id, captcha_solution):
230+ def register(self, email, password, displayname,
231+ captcha_id, captcha_solution):
232 """Fake registration. Return a fix result."""
233 if email == EMAIL_ALREADY_REGISTERED:
234 return {'status': SSO_STATUS_ERROR,
235@@ -148,6 +149,7 @@
236 """Init."""
237 self.processor = Account(sso_service_class=FakedSSOServer)
238 self.register_kwargs = dict(email=EMAIL, password=PASSWORD,
239+ displayname=NAME,
240 captcha_id=CAPTCHA_ID,
241 captcha_solution=CAPTCHA_SOLUTION)
242 self.login_kwargs = dict(email=EMAIL, password=PASSWORD,

Subscribers

People subscribed via source and target branches