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

Proposed by Natalia Bidart
Status: Merged
Approved by: Natalia Bidart
Approved revision: 642
Merged at revision: 642
Proposed branch: lp:~nataliabidart/ubuntu-sso-client/no-more-two-tokens-stable
Merge into: lp:ubuntu-sso-client/stable-1-0
Diff against target: 120 lines (+13/-17)
3 files modified
ubuntu_sso/gui.py (+3/-3)
ubuntu_sso/main.py (+5/-9)
ubuntu_sso/tests/test_main.py (+5/-5)
To merge this branch: bzr merge lp:~nataliabidart/ubuntu-sso-client/no-more-two-tokens-stable
Reviewer Review Type Date Requested Status
Roman Yepishev (community) fieldtest Approve
Roberto Alsina (community) Approve
Review via email: mp+43836@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/

(please note that this has to be done using maverick's syncdaemon, since the syncdaemon in nightlies will use the new SSO api which does not exist in maverick)

To post a comment you must log in.
Revision history for this message
Natalia Bidart (nataliabidart) wrote :

Changes added to gui.py were made to make pylint happy, I was getting:

************* Module ubuntu_sso.gui
W0403: 31: Relative import 'gtk', should be 'ubuntu_sso.gtk'
E1002:123:LabeledEntry.__init__: Use super on an old style class
E1002:162:LabeledEntry.get_text: Use super on an old style class

Revision history for this message
Roberto Alsina (ralsina) wrote :

Confirmed: only one token with this patch.

review: Approve
Revision history for this message
Roman Yepishev (rye) wrote :

No more duplicate tokens in maverick!

review: Approve (fieldtest)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'ubuntu_sso/gui.py'
2--- ubuntu_sso/gui.py 2010-11-03 17:43:17 +0000
3+++ ubuntu_sso/gui.py 2010-12-15 21:49:05 +0000
4@@ -28,7 +28,7 @@
5 import dbus
6 import gettext
7 import gobject
8-import gtk
9+import gtk # pylint: disable=W0403
10 import webkit
11 import xdg
12
13@@ -125,7 +125,7 @@
14 self.is_password = is_password
15 self.warning = None
16
17- super(LabeledEntry, self).__init__(*args, **kwargs)
18+ gtk.Entry.__init__(self, *args, **kwargs)
19
20 self.set_width_chars(DEFAULT_WIDTH)
21 self._set_label(self, None)
22@@ -161,7 +161,7 @@
23
24 def get_text(self):
25 """Get text only if it's not the label nor empty."""
26- result = super(LabeledEntry, self).get_text()
27+ result = gtk.Entry.get_text(self)
28 if result == self.label or result.isspace():
29 result = ''
30 return result
31
32=== modified file 'ubuntu_sso/main.py'
33--- ubuntu_sso/main.py 2010-11-03 19:31:34 +0000
34+++ ubuntu_sso/main.py 2010-12-15 21:49:05 +0000
35@@ -216,12 +216,10 @@
36 'token_name: %r', credentials['consumer_key'], token_name)
37 return credentials
38
39- def is_validated(self, email, password, token_name, sso_service=None):
40+ def is_validated(self, token, sso_service=None):
41 """Return if user with 'email' and 'password' is validated."""
42+ logger.debug('is_validated: requesting accounts.me() info.')
43 if sso_service is None:
44- token = self.login(email=email, password=password,
45- token_name=token_name)
46-
47 oauth_token = oauth.OAuthToken(token['token'],
48 token['token_secret'])
49 authorizer = OAuthAuthorizer(token['consumer_key'],
50@@ -233,8 +231,8 @@
51 key = 'preferred_email'
52 result = key in me_info and me_info[key] != None
53
54- logger.debug('is_validated: email: %r token_name: %r, result: %r.',
55- email, token_name, result)
56+ logger.info('is_validated: consumer_key: %r, result: %r.',
57+ token['consumer_key'], result)
58 return result
59
60 def validate_email(self, email, password, email_token, token_name):
61@@ -424,9 +422,7 @@
62
63 def success_cb(app_name, credentials):
64 """Login finished successfull."""
65- token_name = get_token_name(app_name)
66- is_validated = self.processor.is_validated(email, password,
67- token_name)
68+ is_validated = self.processor.is_validated(credentials)
69 logger.debug('user is validated? %r.', is_validated)
70 if is_validated:
71 keyring_store_credentials(app_name, credentials,
72
73=== modified file 'ubuntu_sso/tests/test_main.py'
74--- ubuntu_sso/tests/test_main.py 2010-11-03 19:01:16 +0000
75+++ ubuntu_sso/tests/test_main.py 2010-12-15 21:49:05 +0000
76@@ -297,7 +297,7 @@
77
78 def test_is_validated(self):
79 """If preferred email is not None, user is validated."""
80- result = self.processor.is_validated(**self.login_kwargs)
81+ result = self.processor.is_validated(token=TOKEN)
82 self.assertTrue(result, 'user must be validated.')
83
84 def test_is_not_validated(self):
85@@ -305,7 +305,7 @@
86 service = FakedSSOServer(None, None)
87 service.accounts.preferred_email = None
88 result = self.processor.is_validated(sso_service=service,
89- **self.login_kwargs)
90+ token=TOKEN)
91 self.assertFalse(result, 'user must not be validated.')
92
93 def test_is_not_validated_empty_result(self):
94@@ -313,7 +313,7 @@
95 service = FakedSSOServer(None, None)
96 service.accounts.me = lambda: {}
97 result = self.processor.is_validated(sso_service=service,
98- **self.login_kwargs)
99+ token=TOKEN)
100 self.assertFalse(result, 'user must not be validated.')
101
102 # validate_email
103@@ -560,7 +560,7 @@
104 processor = self.create_mock_processor()
105 processor.login(EMAIL, PASSWORD, TOKEN_NAME)
106 self.mocker.result(TOKEN)
107- processor.is_validated(EMAIL, PASSWORD, TOKEN_NAME)
108+ processor.is_validated(TOKEN)
109 self.mocker.result(True)
110 self.patch(ubuntu_sso.main, "blocking", self.fake_ok_blocking)
111 self.mocker.replay()
112@@ -586,7 +586,7 @@
113 processor = self.create_mock_processor()
114 processor.login(EMAIL, PASSWORD, TOKEN_NAME)
115 self.mocker.result(TOKEN)
116- processor.is_validated(EMAIL, PASSWORD, TOKEN_NAME)
117+ processor.is_validated(TOKEN)
118 self.mocker.result(False)
119 self.patch(ubuntu_sso.main, "blocking", self.fake_ok_blocking)
120 self.mocker.replay()

Subscribers

People subscribed via source and target branches