Merge lp:~alecu/ubuntuone-windows-installer/timestamp-autofix into lp:ubuntuone-windows-installer

Proposed by Alejandro J. Cura
Status: Merged
Approved by: Natalia Bidart
Approved revision: 79
Merged at revision: 77
Proposed branch: lp:~alecu/ubuntuone-windows-installer/timestamp-autofix
Merge into: lp:ubuntuone-windows-installer
Diff against target: 60 lines (+34/-1)
2 files modified
ubuntuone_installer/gui/qt/local_folders.py (+3/-1)
ubuntuone_installer/gui/qt/tests/test_local_folders.py (+31/-0)
To merge this branch: bzr merge lp:~alecu/ubuntuone-windows-installer/timestamp-autofix
Reviewer Review Type Date Requested Status
Natalia Bidart (community) Approve
Diego Sarmentero (community) Approve
Review via email: mp+78616@code.launchpad.net

Commit message

Do a HEAD request on the server to get accurate timestamp (LP: #692597).

Description of the change

Do a HEAD request on the server to get accurate timestamp (LP: #692597)

This branch depends on:
 * lp:~alecu/ubuntuone-storage-protocol/timestamp-autofix
 * lp:~alecu/ubuntuone-control-panel/timestamp-autofix

To test it on linux, point run-test to the dependent branches, like this:
  PYTHONPATH=~/canonical/ubuntuone-storage-protocol/timestamp-autofix/:~/canonical/ubuntuone-control-panel/timestamp-autofix/ ./run-tests

To post a comment you must log in.
Revision history for this message
Diego Sarmentero (diegosarmentero) wrote :

+1

Revision history for this message
Diego Sarmentero (diegosarmentero) wrote :

+1 approve!

review: Approve
Revision history for this message
Natalia Bidart (nataliabidart) wrote :

Looks great!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'ubuntuone_installer/gui/qt/local_folders.py'
2--- ubuntuone_installer/gui/qt/local_folders.py 2011-09-30 15:36:08 +0000
3+++ ubuntuone_installer/gui/qt/local_folders.py 2011-10-07 14:48:29 +0000
4@@ -30,6 +30,7 @@
5 sign_url,
6 FOLDER_INVALID_PATH,
7 )
8+from ubuntuone.controlpanel.web_client.txwebclient import timestamp_checker
9 from ubuntuone.platform.credentials import CredentialsManagementTool
10 from ubuntu_sso.qt.gui import SSOWizardPage
11
12@@ -280,7 +281,8 @@
13 logger.exception('Error while trying to get credentials:')
14 creds = {}
15 if creds:
16- signed_url = sign_url(url, creds)
17+ timestamp = yield timestamp_checker.get_faithful_time()
18+ signed_url = yield sign_url(url, creds, timestamp)
19 else:
20 signed_url = url
21 QtGui.QDesktopServices.openUrl(QtCore.QUrl(signed_url))
22
23=== modified file 'ubuntuone_installer/gui/qt/tests/test_local_folders.py'
24--- ubuntuone_installer/gui/qt/tests/test_local_folders.py 2011-09-30 15:32:57 +0000
25+++ ubuntuone_installer/gui/qt/tests/test_local_folders.py 2011-10-07 14:48:29 +0000
26@@ -613,3 +613,34 @@
27 "initializePage", self._set_called)
28 self.ui.cleanupPage()
29 self.assertEqual(self._called, ((), {}))
30+
31+ def test_on_add_storage_button_clicked_async_sign_url(self):
32+ """on_add_storage_button_clicked knows that sign_url is async."""
33+ test_url = "http://test/url"
34+ test_timestamp = 1234
35+
36+ def fake_find_credentials(cmt):
37+ """A fake find_credentials."""
38+ return defer.succeed({"fake": "credentials"})
39+
40+ def fake_get_timestamp():
41+ """A fake get_timestamp."""
42+ return defer.succeed(test_timestamp)
43+
44+ def fake_sign_url(url, creds, timestamp):
45+ """A fake sign_url."""
46+ self.assertEqual(timestamp, test_timestamp)
47+ return defer.succeed(test_url)
48+
49+ @staticmethod
50+ def fake_open_url(url):
51+ """A fake QtGui.QDesktopServices.openUrl."""
52+ self.assertEqual(url.toString(), test_url)
53+
54+ self.patch(local_folders.CredentialsManagementTool,
55+ "find_credentials", fake_find_credentials)
56+ self.patch(local_folders.timestamp_checker,
57+ "get_faithful_time", fake_get_timestamp)
58+ self.patch(local_folders, "sign_url", fake_sign_url)
59+ self.patch(QtGui.QDesktopServices, "openUrl", fake_open_url)
60+ self.ui.on_add_storage_button_clicked()

Subscribers

People subscribed via source and target branches