Merge lp:~dobey/ubuntu-sso-client/no-more-ping into lp:ubuntu-sso-client

Proposed by dobey on 2014-08-13
Status: Merged
Approved by: dobey on 2014-08-14
Approved revision: 1040
Merged at revision: 1038
Proposed branch: lp:~dobey/ubuntu-sso-client/no-more-ping
Merge into: lp:ubuntu-sso-client
Diff against target: 361 lines (+18/-182)
11 files modified
ubuntu_sso/constants.py.in (+3/-8)
ubuntu_sso/networkstate/darwin.py (+1/-1)
ubuntu_sso/networkstate/tests/run_nwmgr_standalone.py (+1/-1)
ubuntu_sso/qt/current_user_sign_in_page.py (+1/-5)
ubuntu_sso/qt/email_verification_page.py (+1/-5)
ubuntu_sso/qt/sso_wizard_page.py (+1/-2)
ubuntu_sso/qt/tests/test_current_user_sign_in_page.py (+3/-19)
ubuntu_sso/qt/tests/test_email_verification.py (+3/-22)
ubuntu_sso/utils/__init__.py (+1/-33)
ubuntu_sso/utils/tests/test_common.py (+1/-84)
ubuntu_sso/utils/webclient/timestamp.py (+2/-2)
To merge this branch: bzr merge lp:~dobey/ubuntu-sso-client/no-more-ping
Reviewer Review Type Date Requested Status
Natalia Bidart 2014-08-13 Approve on 2014-08-14
dobey (community) Abstain on 2014-08-13
Review via email: mp+230712@code.launchpad.net

This proposal supersedes a proposal from 2014-08-13.

Commit message

Remove the ping URL usage.
Update the Terms and Privacy URLs to point to login.ubuntu.com.
Update timestamp checking URL to point to login.ubuntu.com.

To post a comment you must log in.
dobey (dobey) wrote : Posted in a previous version of this proposal

/home/dobey/Projects/canonical/ubuntu-sso-client/no-more-ping/ubuntu_sso/utils/__init__.py:
    39: 'defer' imported but unused
    47: 'compat' imported but unused
    47: 'webclient' imported but unused

/home/dobey/Projects/canonical/ubuntu-sso-client/no-more-ping/ubuntu_sso/utils/tests/test_common.py:
    43: 'EMAIL' imported but unused
    43: 'TOKEN' imported but unused

review: Needs Fixing
dobey (dobey) :
review: Abstain
Natalia Bidart (nataliabidart) wrote :

Looks good!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'ubuntu_sso/constants.py.in'
2--- ubuntu_sso/constants.py.in 2013-06-12 14:26:06 +0000
3+++ ubuntu_sso/constants.py.in 2014-08-13 21:12:50 +0000
4@@ -36,7 +36,7 @@
5 import platform
6 import urllib
7
8-from ubuntu_sso import SSO_UONE_BASE_URL
9+from ubuntu_sso import SSO_AUTH_BASE_URL
10
11 VERSION = '@VERSION@'
12 PROJECT_NAME = '@PROJECT_NAME@'
13@@ -45,10 +45,8 @@
14
15 # Ubuntu One sso constants
16 APP_NAME = u"Ubuntu One"
17-TC_URL = u"%s/terms/" % SSO_UONE_BASE_URL
18-POLICY_URL = u"%s/privacy/" % SSO_UONE_BASE_URL
19-BASE_PING_URL = \
20- u"%s/oauth/sso-finished-so-get-tokens/{email}" % SSO_UONE_BASE_URL
21+TC_URL = u"%s/terms/" % SSO_AUTH_BASE_URL
22+POLICY_URL = u"%s/privacy/" % SSO_AUTH_BASE_URL
23
24
25 def platform_data():
26@@ -59,6 +57,3 @@
27 # urlencode will not encode unicode, only bytes
28 result = urllib.urlencode(result)
29 return result
30-
31-# the result of platform_data is given by urlencode, encoded with ascii
32-PING_URL = BASE_PING_URL + u"?" + platform_data().decode('ascii')
33
34=== modified file 'ubuntu_sso/networkstate/darwin.py'
35--- ubuntu_sso/networkstate/darwin.py 2012-06-22 20:03:57 +0000
36+++ ubuntu_sso/networkstate/darwin.py 2014-08-13 21:12:50 +0000
37@@ -28,7 +28,7 @@
38 from ubuntu_sso.logger import setup_logging
39 logger = setup_logging("ubuntu_sso.networkstate")
40
41-HOSTNAME_TO_CHECK = 'one.ubuntu.com'
42+HOSTNAME_TO_CHECK = 'login.ubuntu.com'
43
44 from ctypes import (
45 CDLL,
46
47=== modified file 'ubuntu_sso/networkstate/tests/run_nwmgr_standalone.py'
48--- ubuntu_sso/networkstate/tests/run_nwmgr_standalone.py 2012-06-27 21:58:15 +0000
49+++ ubuntu_sso/networkstate/tests/run_nwmgr_standalone.py 2014-08-13 21:12:50 +0000
50@@ -26,7 +26,7 @@
51
52 def my_cb(state):
53 """simple callback just prints state"""
54- print("one.ubuntu.com:", state)
55+ print("login.ubuntu.com:", state)
56
57 if __name__ == '__main__':
58 # test once with direct call:
59
60=== modified file 'ubuntu_sso/qt/current_user_sign_in_page.py'
61--- ubuntu_sso/qt/current_user_sign_in_page.py 2012-12-04 19:28:44 +0000
62+++ ubuntu_sso/qt/current_user_sign_in_page.py 2014-08-13 21:12:50 +0000
63@@ -150,11 +150,7 @@
64 logger.info('CurrentUserSignInPage.login for: %s', email)
65 password = compat.text_type(self.ui.password_edit.text())
66 args = (self.app_name, email, password)
67- if self.ping_url:
68- f = self.backend.login_and_ping
69- args = args + (self.ping_url,)
70- else:
71- f = self.backend.login
72+ f = self.backend.login
73
74 self.hide_error()
75 self.show_overlay()
76
77=== modified file 'ubuntu_sso/qt/email_verification_page.py'
78--- ubuntu_sso/qt/email_verification_page.py 2012-12-04 19:28:44 +0000
79+++ ubuntu_sso/qt/email_verification_page.py 2014-08-13 21:12:50 +0000
80@@ -120,11 +120,7 @@
81 args = (self.app_name, self.email, self.password, code)
82 self.hide_error()
83 self.show_overlay()
84- if self.ping_url:
85- f = self.backend.validate_email_and_ping
86- args = args + (self.ping_url,)
87- else:
88- f = self.backend.validate_email
89+ f = self.backend.validate_email
90
91 logger.info('Calling validate_email with email %r, password <hidden>, '
92 'app_name %r and email_token %r.', self.email,
93
94=== modified file 'ubuntu_sso/qt/sso_wizard_page.py'
95--- ubuntu_sso/qt/sso_wizard_page.py 2013-06-12 14:26:06 +0000
96+++ ubuntu_sso/qt/sso_wizard_page.py 2014-08-13 21:12:50 +0000
97@@ -45,7 +45,7 @@
98 from twisted.internet import defer
99
100 from ubuntu_sso import main
101-from ubuntu_sso.constants import APP_NAME, TC_URL, POLICY_URL, PING_URL
102+from ubuntu_sso.constants import APP_NAME, TC_URL, POLICY_URL
103 from ubuntu_sso.logger import setup_gui_logging, log_call
104 from ubuntu_sso.qt import (
105 ERROR_STYLE,
106@@ -203,7 +203,6 @@
107
108 # store common useful data provided by the app
109 self.app_name = APP_NAME
110- self.ping_url = PING_URL
111 self.tc_url = TC_URL
112 self.policy_url = POLICY_URL
113 self.help_text = kwargs.get('help_text', '')
114
115=== modified file 'ubuntu_sso/qt/tests/test_current_user_sign_in_page.py'
116--- ubuntu_sso/qt/tests/test_current_user_sign_in_page.py 2013-03-21 13:49:36 +0000
117+++ ubuntu_sso/qt/tests/test_current_user_sign_in_page.py 2014-08-13 21:12:50 +0000
118@@ -136,25 +136,9 @@
119 self.ui._validate()
120 self.assertTrue(button.isEnabled())
121
122- def test_login_with_ping(self):
123- """Test the login method."""
124- self.patch(self.ui, "hide_error", self._set_called)
125- email = 'valid@email'
126- password = '123456'
127- self.ui.ui.email_edit.setText(email)
128- self.ui.ui.password_edit.setText(password)
129- self.ui.login()
130- self.assertEqual(self._overlay_show_counter, 1)
131- self.assertFalse(self.ui.isEnabled())
132- self.assert_backend_called('login_and_ping',
133- self.app_name, email, password, self.ui.ping_url)
134- expected = ((), {})
135- self.assertEqual(expected, self._called)
136-
137- def test_login_without_ping(self):
138- """Test the login method."""
139- self.patch(self.ui, "hide_error", self._set_called)
140- self.ui.ping_url = ''
141+ def test_login(self):
142+ """Test the login method."""
143+ self.patch(self.ui, "hide_error", self._set_called)
144 email = 'valid@email'
145 password = '123456'
146 self.ui.ui.email_edit.setText(email)
147
148=== modified file 'ubuntu_sso/qt/tests/test_email_verification.py'
149--- ubuntu_sso/qt/tests/test_email_verification.py 2013-03-21 13:49:36 +0000
150+++ ubuntu_sso/qt/tests/test_email_verification.py 2014-08-13 21:12:50 +0000
151@@ -126,28 +126,9 @@
152 self.assert_signal_emitted(self.ui.registrationSuccess, (email,),
153 self.ui.on_email_validated, self.app_name, email)
154
155- def test_validate_email_with_ping(self):
156- """Test the login method."""
157- self.patch(self.ui, "hide_error", self._set_called)
158- email = 'email@example.com'
159- password = 'password'
160- code = 'code'
161- self.ui.email = email
162- self.ui.password = password
163- self.ui.ui.verification_code_edit.setText(code)
164-
165- self.ui.validate_email()
166-
167- self.assert_backend_called('validate_email_and_ping',
168- self.app_name, email, password, code, self.ui.ping_url)
169- expected = ((), {})
170- self.assertEqual(expected, self._called)
171- self.assertEqual(self._overlay_show_counter, 1)
172-
173- def test_validate_email_without_ping(self):
174- """Test the login method."""
175- self.patch(self.ui, "hide_error", self._set_called)
176- self.ui.ping_url = ''
177+ def test_validate_email(self):
178+ """Test the login method."""
179+ self.patch(self.ui, "hide_error", self._set_called)
180 email = 'email@example.com'
181 password = 'password'
182 code = 'code'
183
184=== modified file 'ubuntu_sso/utils/__init__.py'
185--- ubuntu_sso/utils/__init__.py 2013-05-08 18:38:36 +0000
186+++ ubuntu_sso/utils/__init__.py 2014-08-13 21:12:50 +0000
187@@ -36,7 +36,6 @@
188 from dirspec.basedir import load_config_paths
189 from dirspec.utils import get_program_path
190
191-from twisted.internet import defer
192 from twisted.python import procutils
193
194 from ubuntu_sso import (BACKEND_EXECUTABLE,
195@@ -44,7 +43,6 @@
196 UI_PROXY_CREDS_DIALOG,
197 UI_SSL_DIALOG)
198 from ubuntu_sso.logger import setup_logging
199-from ubuntu_sso.utils import compat, webclient
200
201
202 logger = setup_logging("ubuntu_sso.utils")
203@@ -166,35 +164,5 @@
204 return ssl_cert_location
205
206
207-@defer.inlineCallbacks
208 def ping_url(url, email, credentials):
209- """Ping the 'url' with the 'email' attached to it.
210-
211- Sign the request with 'credentials'. The url must not be None.
212-
213- """
214- logger.info('Pinging server using url: %r, email: %r.',
215- url, email)
216- assert isinstance(url, compat.text_type), 'Url %r must be unicode' % url
217-
218- target_url = url
219- try:
220- target_url = url.format(email=email)
221- except IndexError: # tuple index out of range
222- target_url = url.format(email) # format the first substitution
223-
224- if target_url == url:
225- logger.debug('Original url (%r) could not be formatted, '
226- 'appending email (%r).', url, email)
227- assert url.endswith('/'), 'Url %r must end with /.' % url
228- target_url = url + email
229-
230- wc = webclient.webclient_factory()
231- try:
232- logger.debug('Opening the url %r with webclient.request.', url)
233- response = yield wc.request(target_url, oauth_credentials=credentials)
234- logger.debug('Url %r opened. Response content: %r.',
235- url, response.content)
236- defer.returnValue(response)
237- finally:
238- wc.shutdown()
239+ """Unused -- it was formerly used to let U1 know about new accounts."""
240
241=== modified file 'ubuntu_sso/utils/tests/test_common.py'
242--- ubuntu_sso/utils/tests/test_common.py 2013-05-22 20:14:40 +0000
243+++ ubuntu_sso/utils/tests/test_common.py 2014-08-13 21:12:50 +0000
244@@ -40,7 +40,7 @@
245 from ubuntuone.devtools.testing.txwebserver import HTTPWebServer
246
247 from ubuntu_sso import utils
248-from ubuntu_sso.tests import TestCase, EMAIL, TOKEN
249+from ubuntu_sso.tests import TestCase
250
251 CONSTANTS_MODULE = 'ubuntu_sso.constants'
252 NOT_DEFINED = object()
253@@ -238,86 +238,3 @@
254 # pylint: disable=E1101
255 root = RootResource()
256 super(MockWebServer, self).__init__(root)
257-
258-
259-class FakedError(Exception):
260- """A mock, test, sample, and fake exception."""
261-
262-
263-class PingUrlTestCase(TestCase):
264- """Test suite for the URL pinging."""
265-
266- @defer.inlineCallbacks
267- def setUp(self):
268- yield super(PingUrlTestCase, self).setUp()
269- self.url = 'http://example.com/'
270- self.wc = FakeWebclient()
271- self.patch(utils.webclient, "webclient_factory",
272- lambda *args: self.wc)
273-
274- @defer.inlineCallbacks
275- def test_ping_url(self):
276- """The url is opened."""
277- yield utils.ping_url(url=self.url, email=EMAIL, credentials=TOKEN)
278-
279- args, _kwargs = self.wc.called[0]
280- self.assertEqual(args[0], self.url + EMAIL)
281-
282- @defer.inlineCallbacks
283- def test_ping_url_result(self):
284- """The result is returned."""
285- result = yield utils.ping_url(url=self.url, email=EMAIL,
286- credentials=TOKEN)
287- self.assertEqual(result.content, 'response')
288-
289- @defer.inlineCallbacks
290- def test_request_is_signed_with_credentials(self):
291- """The http request to url is signed with the credentials."""
292- yield utils.ping_url(url=self.url, email=EMAIL, credentials=TOKEN)
293-
294- _args, kwargs = self.wc.called[0]
295- self.assertEqual(kwargs["oauth_credentials"], TOKEN)
296-
297- @defer.inlineCallbacks
298- def test_ping_url_formatting(self):
299- """The email is added as the first formatting argument."""
300- self.url = 'http://example.com/{email}/something/else'
301- yield utils.ping_url(url=self.url, email=EMAIL, credentials=TOKEN)
302-
303- expected = self.url.format(email=EMAIL)
304- assert len(self.wc.called) > 0
305- args, _kwargs = self.wc.called[0]
306- self.assertEqual(expected, args[0])
307-
308- @defer.inlineCallbacks
309- def test_ping_url_formatting_with_query_params(self):
310- """The email is added as the first formatting argument."""
311- self.url = 'http://example.com/{email}?something=else'
312- yield utils.ping_url(url=self.url, email=EMAIL, credentials=TOKEN)
313-
314- expected = self.url.format(email=EMAIL)
315- assert len(self.wc.called) > 0
316- args, _kwargs = self.wc.called[0]
317- self.assertEqual(expected, args[0])
318-
319- @defer.inlineCallbacks
320- def test_ping_url_formatting_no_email_kwarg(self):
321- """The email is added as the first formatting argument."""
322- self.url = 'http://example.com/{0}/yadda/?something=else'
323- yield utils.ping_url(url=self.url, email=EMAIL, credentials=TOKEN)
324-
325- expected = self.url.format(EMAIL)
326- assert len(self.wc.called) > 0
327- args, _kwargs = self.wc.called[0]
328- self.assertEqual(expected, args[0])
329-
330- @defer.inlineCallbacks
331- def test_ping_url_formatting_no_format(self):
332- """The email is appended if formatting could not be accomplished."""
333- self.url = 'http://example.com/yadda/'
334- yield utils.ping_url(url=self.url, email=EMAIL, credentials=TOKEN)
335-
336- expected = self.url + EMAIL
337- assert len(self.wc.called) > 0
338- args, _kwargs = self.wc.called[0]
339- self.assertEqual(expected, args[0])
340
341=== modified file 'ubuntu_sso/utils/webclient/timestamp.py'
342--- ubuntu_sso/utils/webclient/timestamp.py 2013-04-19 15:32:17 +0000
343+++ ubuntu_sso/utils/webclient/timestamp.py 2014-08-13 21:12:50 +0000
344@@ -32,7 +32,7 @@
345
346 from twisted.internet import defer
347
348-from ubuntu_sso import SSO_UONE_BASE_URL
349+from ubuntu_sso import SSO_AUTH_BASE_URL
350 from ubuntu_sso.logger import setup_logging
351
352 logger = setup_logging("ubuntu_sso.utils.webclient.timestamp")
353@@ -44,7 +44,7 @@
354
355 CHECKING_INTERVAL = 60 * 60 # in seconds
356 ERROR_INTERVAL = 30 # in seconds
357- SERVER_IRI = u"%s/api/time" % SSO_UONE_BASE_URL
358+ SERVER_IRI = SSO_AUTH_BASE_URL
359
360 def __init__(self, webclient_class):
361 """Initialize this instance."""

Subscribers

People subscribed via source and target branches