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

Proposed by Natalia Bidart
Status: Merged
Approved by: Natalia Bidart
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
Roman Yepishev (community) fieldtest Approve
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.
Revision history for this message
Roman Yepishev (rye) wrote :

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

review: Approve (fieldtest)
Revision history for this message
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
1=== modified file 'ubuntu_sso/account.py'
2--- ubuntu_sso/account.py 2010-11-22 18:46:04 +0000
3+++ ubuntu_sso/account.py 2010-12-15 20:52:34 +0000
4@@ -172,12 +172,10 @@
5 'token_name: %r', credentials['consumer_key'], token_name)
6 return credentials
7
8- def is_validated(self, email, password, token_name, sso_service=None):
9+ def is_validated(self, token, sso_service=None):
10 """Return if user with 'email' and 'password' is validated."""
11+ logger.debug('is_validated: requesting accounts.me() info.')
12 if sso_service is None:
13- token = self.login(email=email, password=password,
14- token_name=token_name)
15-
16 oauth_token = oauth.OAuthToken(token['token'],
17 token['token_secret'])
18 authorizer = OAuthAuthorizer(token['consumer_key'],
19@@ -189,8 +187,8 @@
20 key = 'preferred_email'
21 result = key in me_info and me_info[key] != None
22
23- logger.debug('is_validated: email: %r token_name: %r, result: %r.',
24- email, token_name, result)
25+ logger.info('is_validated: consumer_key: %r, result: %r.',
26+ token['consumer_key'], result)
27 return result
28
29 def validate_email(self, email, password, email_token, token_name):
30
31=== modified file 'ubuntu_sso/main.py'
32--- ubuntu_sso/main.py 2010-11-24 17:58:00 +0000
33+++ ubuntu_sso/main.py 2010-12-15 20:52:34 +0000
34@@ -192,9 +192,7 @@
35
36 def success_cb(app_name, credentials):
37 """Login finished successfull."""
38- token_name = get_token_name(app_name)
39- is_validated = self.processor.is_validated(email, password,
40- token_name)
41+ is_validated = self.processor.is_validated(credentials)
42 logger.debug('user is validated? %r.', is_validated)
43 if is_validated:
44 # pylint: disable=E1101
45
46=== modified file 'ubuntu_sso/tests/test_account.py'
47--- ubuntu_sso/tests/test_account.py 2010-11-22 18:46:04 +0000
48+++ ubuntu_sso/tests/test_account.py 2010-12-15 20:52:34 +0000
49@@ -249,7 +249,7 @@
50
51 def test_is_validated(self):
52 """If preferred email is not None, user is validated."""
53- result = self.processor.is_validated(**self.login_kwargs)
54+ result = self.processor.is_validated(token=TOKEN)
55 self.assertTrue(result, 'user must be validated.')
56
57 def test_is_not_validated(self):
58@@ -257,7 +257,7 @@
59 service = FakedSSOServer(None, None)
60 service.accounts.preferred_email = None
61 result = self.processor.is_validated(sso_service=service,
62- **self.login_kwargs)
63+ token=TOKEN)
64 self.assertFalse(result, 'user must not be validated.')
65
66 def test_is_not_validated_empty_result(self):
67@@ -265,7 +265,7 @@
68 service = FakedSSOServer(None, None)
69 service.accounts.me = lambda: {}
70 result = self.processor.is_validated(sso_service=service,
71- **self.login_kwargs)
72+ token=TOKEN)
73 self.assertFalse(result, 'user must not be validated.')
74
75 # validate_email
76
77=== modified file 'ubuntu_sso/tests/test_main.py'
78--- ubuntu_sso/tests/test_main.py 2010-11-24 12:48:28 +0000
79+++ ubuntu_sso/tests/test_main.py 2010-12-15 20:52:34 +0000
80@@ -210,7 +210,7 @@
81 processor = self.create_mock_processor()
82 processor.login(EMAIL, PASSWORD, TOKEN_NAME)
83 self.mocker.result(TOKEN)
84- processor.is_validated(EMAIL, PASSWORD, TOKEN_NAME)
85+ processor.is_validated(TOKEN)
86 self.mocker.result(True)
87 self.patch(ubuntu_sso.main, "blocking", fake_ok_blocking)
88 self.mocker.replay()
89@@ -236,7 +236,7 @@
90 processor = self.create_mock_processor()
91 processor.login(EMAIL, PASSWORD, TOKEN_NAME)
92 self.mocker.result(TOKEN)
93- processor.is_validated(EMAIL, PASSWORD, TOKEN_NAME)
94+ processor.is_validated(TOKEN)
95 self.mocker.result(False)
96 self.patch(ubuntu_sso.main, "blocking", fake_ok_blocking)
97 self.mocker.replay()

Subscribers

People subscribed via source and target branches