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
=== modified file 'ubuntuone_installer/gui/qt/local_folders.py'
--- ubuntuone_installer/gui/qt/local_folders.py 2011-09-30 15:36:08 +0000
+++ ubuntuone_installer/gui/qt/local_folders.py 2011-10-07 14:48:29 +0000
@@ -30,6 +30,7 @@
30 sign_url,30 sign_url,
31 FOLDER_INVALID_PATH,31 FOLDER_INVALID_PATH,
32)32)
33from ubuntuone.controlpanel.web_client.txwebclient import timestamp_checker
33from ubuntuone.platform.credentials import CredentialsManagementTool34from ubuntuone.platform.credentials import CredentialsManagementTool
34from ubuntu_sso.qt.gui import SSOWizardPage35from ubuntu_sso.qt.gui import SSOWizardPage
3536
@@ -280,7 +281,8 @@
280 logger.exception('Error while trying to get credentials:')281 logger.exception('Error while trying to get credentials:')
281 creds = {}282 creds = {}
282 if creds:283 if creds:
283 signed_url = sign_url(url, creds)284 timestamp = yield timestamp_checker.get_faithful_time()
285 signed_url = yield sign_url(url, creds, timestamp)
284 else:286 else:
285 signed_url = url287 signed_url = url
286 QtGui.QDesktopServices.openUrl(QtCore.QUrl(signed_url))288 QtGui.QDesktopServices.openUrl(QtCore.QUrl(signed_url))
287289
=== modified file 'ubuntuone_installer/gui/qt/tests/test_local_folders.py'
--- ubuntuone_installer/gui/qt/tests/test_local_folders.py 2011-09-30 15:32:57 +0000
+++ ubuntuone_installer/gui/qt/tests/test_local_folders.py 2011-10-07 14:48:29 +0000
@@ -613,3 +613,34 @@
613 "initializePage", self._set_called)613 "initializePage", self._set_called)
614 self.ui.cleanupPage()614 self.ui.cleanupPage()
615 self.assertEqual(self._called, ((), {}))615 self.assertEqual(self._called, ((), {}))
616
617 def test_on_add_storage_button_clicked_async_sign_url(self):
618 """on_add_storage_button_clicked knows that sign_url is async."""
619 test_url = "http://test/url"
620 test_timestamp = 1234
621
622 def fake_find_credentials(cmt):
623 """A fake find_credentials."""
624 return defer.succeed({"fake": "credentials"})
625
626 def fake_get_timestamp():
627 """A fake get_timestamp."""
628 return defer.succeed(test_timestamp)
629
630 def fake_sign_url(url, creds, timestamp):
631 """A fake sign_url."""
632 self.assertEqual(timestamp, test_timestamp)
633 return defer.succeed(test_url)
634
635 @staticmethod
636 def fake_open_url(url):
637 """A fake QtGui.QDesktopServices.openUrl."""
638 self.assertEqual(url.toString(), test_url)
639
640 self.patch(local_folders.CredentialsManagementTool,
641 "find_credentials", fake_find_credentials)
642 self.patch(local_folders.timestamp_checker,
643 "get_faithful_time", fake_get_timestamp)
644 self.patch(local_folders, "sign_url", fake_sign_url)
645 self.patch(QtGui.QDesktopServices, "openUrl", fake_open_url)
646 self.ui.on_add_storage_button_clicked()

Subscribers

People subscribed via source and target branches