Merge lp:~nataliabidart/ubuntu-sso-client/no-more-two-tokens into lp:ubuntu-sso-client

Proposed by Natalia Bidart on 2010-12-15
Status: Merged
Approved by: Natalia Bidart on 2010-12-15
Approved revision: 662
Merged at revision: 662
Proposed branch: lp:~nataliabidart/ubuntu-sso-client/no-more-two-tokens
Merge into: lp:ubuntu-sso-client
Diff against target: 97 lines (+10/-14)
4 files modified
ubuntu_sso/account.py (+4/-6)
ubuntu_sso/main.py (+1/-3)
ubuntu_sso/tests/test_account.py (+3/-3)
ubuntu_sso/tests/test_main.py (+2/-2)
To merge this branch: bzr merge lp:~nataliabidart/ubuntu-sso-client/no-more-two-tokens
Reviewer Review Type Date Requested Status
Roberto Alsina (community) Approve on 2010-12-15
Roman Yepishev (community) fieldtest 2010-12-15 Approve on 2010-12-15
Review via email: mp+43826@code.launchpad.net

Commit message

* Avoid generating an extra token when attempting to validate a user account (LP: #687523).

Description of the change

To test, run from this branch:

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

Remove all your Ubuntu One credentials in seahorse, in https://login.ubuntu.com/+applications and in https://one.ubuntu.com/account/machines/

Re-add your computer to Ubuntu One with issuing:

u1sdtool -d
u1sdtool -c

Confirm that only one token is added in both:

https://login.ubuntu.com/+applications and https://one.ubuntu.com/account/machines/

To post a comment you must log in.
Roman Yepishev (rye) wrote :

login.ubuntu.com: one token
one.ubuntu.com/account/machines: one token. All OK

review: Approve (fieldtest)
Roberto Alsina (ralsina) wrote :

Verified, one token only.

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-11-22 18:46:04 +0000
+++ ubuntu_sso/account.py 2010-12-15 20:52:34 +0000
@@ -172,12 +172,10 @@
172 'token_name: %r', credentials['consumer_key'], token_name)172 'token_name: %r', credentials['consumer_key'], token_name)
173 return credentials173 return credentials
174174
175 def is_validated(self, email, password, token_name, sso_service=None):175 def is_validated(self, token, sso_service=None):
176 """Return if user with 'email' and 'password' is validated."""176 """Return if user with 'email' and 'password' is validated."""
177 logger.debug('is_validated: requesting accounts.me() info.')
177 if sso_service is None:178 if sso_service is None:
178 token = self.login(email=email, password=password,
179 token_name=token_name)
180
181 oauth_token = oauth.OAuthToken(token['token'],179 oauth_token = oauth.OAuthToken(token['token'],
182 token['token_secret'])180 token['token_secret'])
183 authorizer = OAuthAuthorizer(token['consumer_key'],181 authorizer = OAuthAuthorizer(token['consumer_key'],
@@ -189,8 +187,8 @@
189 key = 'preferred_email'187 key = 'preferred_email'
190 result = key in me_info and me_info[key] != None188 result = key in me_info and me_info[key] != None
191189
192 logger.debug('is_validated: email: %r token_name: %r, result: %r.',190 logger.info('is_validated: consumer_key: %r, result: %r.',
193 email, token_name, result)191 token['consumer_key'], result)
194 return result192 return result
195193
196 def validate_email(self, email, password, email_token, token_name):194 def validate_email(self, email, password, email_token, token_name):
197195
=== modified file 'ubuntu_sso/main.py'
--- ubuntu_sso/main.py 2010-11-24 17:58:00 +0000
+++ ubuntu_sso/main.py 2010-12-15 20:52:34 +0000
@@ -192,9 +192,7 @@
192192
193 def success_cb(app_name, credentials):193 def success_cb(app_name, credentials):
194 """Login finished successfull."""194 """Login finished successfull."""
195 token_name = get_token_name(app_name)195 is_validated = self.processor.is_validated(credentials)
196 is_validated = self.processor.is_validated(email, password,
197 token_name)
198 logger.debug('user is validated? %r.', is_validated)196 logger.debug('user is validated? %r.', is_validated)
199 if is_validated:197 if is_validated:
200 # pylint: disable=E1101198 # pylint: disable=E1101
201199
=== modified file 'ubuntu_sso/tests/test_account.py'
--- ubuntu_sso/tests/test_account.py 2010-11-22 18:46:04 +0000
+++ ubuntu_sso/tests/test_account.py 2010-12-15 20:52:34 +0000
@@ -249,7 +249,7 @@
249249
250 def test_is_validated(self):250 def test_is_validated(self):
251 """If preferred email is not None, user is validated."""251 """If preferred email is not None, user is validated."""
252 result = self.processor.is_validated(**self.login_kwargs)252 result = self.processor.is_validated(token=TOKEN)
253 self.assertTrue(result, 'user must be validated.')253 self.assertTrue(result, 'user must be validated.')
254254
255 def test_is_not_validated(self):255 def test_is_not_validated(self):
@@ -257,7 +257,7 @@
257 service = FakedSSOServer(None, None)257 service = FakedSSOServer(None, None)
258 service.accounts.preferred_email = None258 service.accounts.preferred_email = None
259 result = self.processor.is_validated(sso_service=service,259 result = self.processor.is_validated(sso_service=service,
260 **self.login_kwargs)260 token=TOKEN)
261 self.assertFalse(result, 'user must not be validated.')261 self.assertFalse(result, 'user must not be validated.')
262262
263 def test_is_not_validated_empty_result(self):263 def test_is_not_validated_empty_result(self):
@@ -265,7 +265,7 @@
265 service = FakedSSOServer(None, None)265 service = FakedSSOServer(None, None)
266 service.accounts.me = lambda: {}266 service.accounts.me = lambda: {}
267 result = self.processor.is_validated(sso_service=service,267 result = self.processor.is_validated(sso_service=service,
268 **self.login_kwargs)268 token=TOKEN)
269 self.assertFalse(result, 'user must not be validated.')269 self.assertFalse(result, 'user must not be validated.')
270270
271 # validate_email271 # validate_email
272272
=== modified file 'ubuntu_sso/tests/test_main.py'
--- ubuntu_sso/tests/test_main.py 2010-11-24 12:48:28 +0000
+++ ubuntu_sso/tests/test_main.py 2010-12-15 20:52:34 +0000
@@ -210,7 +210,7 @@
210 processor = self.create_mock_processor()210 processor = self.create_mock_processor()
211 processor.login(EMAIL, PASSWORD, TOKEN_NAME)211 processor.login(EMAIL, PASSWORD, TOKEN_NAME)
212 self.mocker.result(TOKEN)212 self.mocker.result(TOKEN)
213 processor.is_validated(EMAIL, PASSWORD, TOKEN_NAME)213 processor.is_validated(TOKEN)
214 self.mocker.result(True)214 self.mocker.result(True)
215 self.patch(ubuntu_sso.main, "blocking", fake_ok_blocking)215 self.patch(ubuntu_sso.main, "blocking", fake_ok_blocking)
216 self.mocker.replay()216 self.mocker.replay()
@@ -236,7 +236,7 @@
236 processor = self.create_mock_processor()236 processor = self.create_mock_processor()
237 processor.login(EMAIL, PASSWORD, TOKEN_NAME)237 processor.login(EMAIL, PASSWORD, TOKEN_NAME)
238 self.mocker.result(TOKEN)238 self.mocker.result(TOKEN)
239 processor.is_validated(EMAIL, PASSWORD, TOKEN_NAME)239 processor.is_validated(TOKEN)
240 self.mocker.result(False)240 self.mocker.result(False)
241 self.patch(ubuntu_sso.main, "blocking", fake_ok_blocking)241 self.patch(ubuntu_sso.main, "blocking", fake_ok_blocking)
242 self.mocker.replay()242 self.mocker.replay()

Subscribers

People subscribed via source and target branches