Merge lp:~alecu/ubuntuone-client/timestamp-autofix-2-0 into lp:ubuntuone-client/stable-2-0

Proposed by Alejandro J. Cura
Status: Merged
Approved by: Alejandro J. Cura
Approved revision: 1144
Merged at revision: 1143
Proposed branch: lp:~alecu/ubuntuone-client/timestamp-autofix-2-0
Merge into: lp:ubuntuone-client/stable-2-0
Diff against target: 237 lines (+80/-26)
3 files modified
Makefile.am (+1/-1)
tests/syncdaemon/test_action_queue.py (+65/-12)
ubuntuone/syncdaemon/action_queue.py (+14/-13)
To merge this branch: bzr merge lp:~alecu/ubuntuone-client/timestamp-autofix-2-0
Reviewer Review Type Date Requested Status
Natalia Bidart (community) Approve
Diego Sarmentero (community) Abstain
Review via email: mp+82753@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-2-0
 * lp:~alecu/ubuntu-sso-client/timestamp-autofix-1-4

To build it on linux, point autogen to the dependent branches, like this:
./autogen.sh --with-protocol=$HOME/canonical/ubuntuone-storage-protocol/timestamp-autofix-2-0/ --with-sso=$HOME/canonical/ubuntu-sso-client/timestamp-autofix-1-4/

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

Text conflict in tests/platform/linux/eventlog/test_zglog.py
Text conflict in tests/platform/linux/test_dbus.py
Text conflict in tests/platform/linux/test_messaging.py
Text conflict in tests/platform/linux/test_notification.py
Text conflict in tests/status/test_aggregator.py
Text conflict in tests/syncdaemon/test_action_queue.py
Text conflict in tests/syncdaemon/test_interaction_interfaces.py
Text conflict in ubuntuone/syncdaemon/action_queue.py
8 conflicts encountered.

review: Needs Fixing
Revision history for this message
Diego Sarmentero (diegosarmentero) :
review: Abstain
Revision history for this message
Natalia Bidart (nataliabidart) wrote :

Looks good, test pass, IRL tested. Great work!

review: Approve
Revision history for this message
Ubuntu One Auto Pilot (otto-pilot) wrote :
Download full text (33.9 KiB)

The attempt to merge lp:~alecu/ubuntuone-client/timestamp-autofix-2-0 into lp:ubuntuone-client/stable-2-0 failed. Below is the output from the failed tests.

/usr/bin/gnome-autogen.sh
checking for autoconf >= 2.53...
  testing autoconf2.50... not found.
  testing autoconf... found 2.67
checking for automake >= 1.10...
  testing automake-1.11... found 1.11.1
checking for libtool >= 1.5...
  testing libtoolize... found 2.2.6b
checking for intltool >= 0.30...
  testing intltoolize... found 0.41.1
checking for pkg-config >= 0.14.0...
  testing pkg-config... found 0.25
checking for gtk-doc >= 1.0...
  testing gtkdocize... found 1.17
Checking for required M4 macros...
Checking for forbidden M4 macros...
Processing ./configure.ac
Running libtoolize...
libtoolize: putting auxiliary files in `.'.
libtoolize: copying file `./ltmain.sh'
libtoolize: putting macros in AC_CONFIG_MACRO_DIR, `m4'.
libtoolize: copying file `m4/libtool.m4'
libtoolize: copying file `m4/ltoptions.m4'
libtoolize: copying file `m4/ltsugar.m4'
libtoolize: copying file `m4/ltversion.m4'
libtoolize: copying file `m4/lt~obsolete.m4'
Running intltoolize...
Running gtkdocize...
Running aclocal-1.11...
Running autoconf...
Running autoheader...
Running automake-1.11...
Running ./configure --enable-gtk-doc --enable-debug ...
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... no
checking for mawk... mawk
checking whether make sets $(MAKE)... yes
checking for style of include used by make... GNU
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking dependency style of gcc... gcc3
checking for library containing strerror... none required
checking for gcc... (cached) gcc
checking whether we are using the GNU C compiler... (cached) yes
checking whether gcc accepts -g... (cached) yes
checking for gcc option to accept ISO C89... (cached) none needed
checking dependency style of gcc... (cached) gcc3
checking build system type... i686-pc-linux-gnu
checking host system type... i686-pc-linux-gnu
checking for a sed that does not truncate output... /bin/sed
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for fgrep... /bin/grep -F
checking for ld used by gcc... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -B
checking the name lister (/usr/bin/nm -B) interface... BSD nm
checking whether ln -s works... yes
checking the maximum length of command line arguments... 1572864
checking whether the shell understands some XSI constructs... yes
checking whether the shell understands "+="... yes
checking for /usr/bin/ld option to reload object files... -r
checking for objdump... objdump
c...

1144. By Alejandro J. Cura

fix u1trial parameters

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'Makefile.am'
2--- Makefile.am 2011-07-21 15:24:02 +0000
3+++ Makefile.am 2011-12-13 16:19:23 +0000
4@@ -53,7 +53,7 @@
5 test: logging.conf $(clientdefs_DATA) Makefile
6 echo "$(PYTHONPATH)"
7 if test "x$(builddir)" == "x$(srcdir)"; then \
8- PYTHONPATH="$(PYTHONPATH)" u1trial tests -p tests/platform/windows; \
9+ PYTHONPATH="$(PYTHONPATH)" u1trial -p tests/platform/windows tests; \
10 fi
11 rm -rf _trial_temp
12
13
14=== modified file 'tests/syncdaemon/test_action_queue.py'
15--- tests/syncdaemon/test_action_queue.py 2011-11-07 17:14:04 +0000
16+++ tests/syncdaemon/test_action_queue.py 2011-12-13 16:19:23 +0000
17@@ -2629,6 +2629,8 @@
18 '{"is_public": true, "public_url": "http://example.com"}')
19
20 from ubuntuone.syncdaemon import action_queue
21+ self.patch(action_queue.timestamp_checker, "get_faithful_time",
22+ lambda: 1)
23 action_queue.urlopen = check
24 try:
25 res = self.command._change_public_access_http()
26@@ -2638,6 +2640,22 @@
27 self.assertEqual(
28 {'is_public': True, 'public_url': 'http://example.com'}, res)
29
30+ def test_change_public_access_http_uses_timestamp(self):
31+ """The timestamp is used for oauth signing."""
32+ fake_timestamp = 12345678
33+
34+ def fake_urlopen(request):
35+ """A fake urlopen."""
36+ auth = request.headers["Authorization"]
37+ expected = 'oauth_timestamp="%d"' % fake_timestamp
38+ self.assertIn(expected, auth)
39+ return StringIO("[]")
40+
41+ self.patch(action_queue.timestamp_checker, "get_faithful_time",
42+ lambda: fake_timestamp)
43+ self.patch(action_queue, "urlopen", fake_urlopen)
44+ self.command._change_public_access_http()
45+
46 def test_handle_success_push_event(self):
47 """Test AQ_CHANGE_PUBLIC_ACCESS_OK is pushed on success."""
48 response = {'is_public': True, 'public_url': 'http://example.com'}
49@@ -2732,6 +2750,8 @@
50 '"http://example.com"}]' % (nodekey, nodekey_2, volume_id))
51
52 from ubuntuone.syncdaemon import action_queue
53+ self.patch(action_queue.timestamp_checker, "get_faithful_time",
54+ lambda: 1)
55 action_queue.urlopen = check
56 try:
57 res = self.command._get_public_files_http()
58@@ -2743,6 +2763,22 @@
59 'volume_id': str(volume_id),
60 'public_url': 'http://example.com'}], res)
61
62+ def test_get_public_files_http_uses_timestamp(self):
63+ """The timestamp is used for oauth signing."""
64+ fake_timestamp = 12345678
65+
66+ def fake_urlopen(request):
67+ """A fake urlopen."""
68+ auth = request.headers["Authorization"]
69+ expected = 'oauth_timestamp="%d"' % fake_timestamp
70+ self.assertIn(expected, auth)
71+ return StringIO("[]")
72+
73+ self.patch(action_queue.timestamp_checker, "get_faithful_time",
74+ lambda: fake_timestamp)
75+ self.patch(action_queue, "urlopen", fake_urlopen)
76+ self.command._get_public_files_http()
77+
78 def test_handle_success_push_event(self):
79 """Test AQ_PUBLIC_FILES_LIST_OK is pushed on success."""
80 response = [{'node_id': uuid.uuid4(), 'volume_id':None,
81@@ -3684,23 +3720,18 @@
82 """Init."""
83 yield super(CreateShareTestCase, self).setUp()
84 self.request_queue = RequestQueue(action_queue=self.action_queue)
85- self.orig_create_share_http = CreateShare._create_share_http
86-
87- @defer.inlineCallbacks
88- def tearDown(self):
89- yield super(CreateShareTestCase, self).tearDown()
90- CreateShare._create_share_http = self.orig_create_share_http
91
92 @defer.inlineCallbacks
93 def test_access_level_modify_http(self):
94 """Test proper handling of the access level in the http case."""
95 # replace _create_share_http with a fake, just to check the args
96 d = defer.Deferred()
97- def check_create_http(self, node_id, user, name, read_only, deferred):
98+
99+ def check_create_http(self, node_id, user, name, read_only):
100 """Fire the deferred with the args."""
101 d.callback((node_id, user, name, read_only))
102- deferred.callback(None)
103- CreateShare._create_share_http = check_create_http
104+
105+ self.patch(CreateShare, "_create_share_http", check_create_http)
106 command = CreateShare(self.request_queue, 'node_id',
107 'share_to@example.com', 'share_name',
108 'Modify', 'marker', 'path')
109@@ -3718,11 +3749,12 @@
110 """Test proper handling of the access level in the http case."""
111 # replace _create_share_http with a fake, just to check the args
112 d = defer.Deferred()
113- def check_create_http(self, node_id, user, name, read_only, deferred):
114+
115+ def check_create_http(self, node_id, user, name, read_only):
116 """Fire the deferred with the args."""
117 d.callback((node_id, user, name, read_only))
118- deferred.callback(None)
119- CreateShare._create_share_http = check_create_http
120+
121+ self.patch(CreateShare, "_create_share_http", check_create_http)
122 command = CreateShare(self.request_queue, 'node_id',
123 'share_to@example.com', 'share_name',
124 'View', 'marker', 'path')
125@@ -3734,6 +3766,27 @@
126 self.assertEqual('share_name', name)
127 self.assertTrue(read_only)
128
129+ @defer.inlineCallbacks
130+ def test_create_share_http_uses_timestamp(self):
131+ """The timestamp is used for oauth signing."""
132+ fake_timestamp = 12345678
133+
134+ def fake_urlopen(request):
135+ """A fake urlopen."""
136+ auth = request.headers["Authorization"]
137+ expected = 'oauth_timestamp="%d"' % fake_timestamp
138+ self.assertIn(expected, auth)
139+
140+ self.patch(action_queue.timestamp_checker, "get_faithful_time",
141+ lambda: fake_timestamp)
142+ self.patch(action_queue, "urlopen", fake_urlopen)
143+ self.user_connect()
144+ command = CreateShare(self.request_queue, 'node_id',
145+ 'share_to@example.com', 'share_name',
146+ 'View', 'marker', 'path')
147+ self.assertTrue(command.use_http, 'CreateShare should be in http mode')
148+ yield command._run()
149+
150 def test_possible_markers(self):
151 """Test that it returns the correct values."""
152 cmd = CreateShare(self.request_queue, 'node_id', 'shareto@example.com',
153
154=== modified file 'ubuntuone/syncdaemon/action_queue.py'
155--- ubuntuone/syncdaemon/action_queue.py 2011-11-07 17:14:04 +0000
156+++ ubuntuone/syncdaemon/action_queue.py 2011-12-13 16:19:23 +0000
157@@ -51,6 +51,7 @@
158 from twisted.python.failure import Failure, DefaultException
159
160 from oauth import oauth
161+from ubuntu_sso.utils import timestamp_checker
162 from ubuntuone import clientdefs
163 from ubuntuone.platform import platform, remove_file
164 from ubuntuone.storageprotocol import protocol_pb2, content_hash
165@@ -1735,14 +1736,17 @@
166 if share_to and re.match(EREGEX, share_to):
167 self.use_http = True
168
169- def _create_share_http(self, node_id, user, name, read_only, deferred):
170+ def _create_share_http(self, node_id, user, name, read_only):
171 """Create a share using the HTTP Web API method."""
172
173 url = "https://one.ubuntu.com/files/api/offer_share/"
174 method = oauth.OAuthSignatureMethod_PLAINTEXT()
175+ timestamp = timestamp_checker.get_faithful_time()
176+ parameters = {"oauth_timestamp": timestamp}
177 request = oauth.OAuthRequest.from_consumer_and_token(
178 http_url=url,
179 http_method="POST",
180+ parameters=parameters,
181 oauth_consumer=self.action_queue.consumer,
182 token=self.action_queue.token)
183 request.sign_request(method, self.action_queue.consumer,
184@@ -1754,24 +1758,15 @@
185 pdata = urlencode(data)
186 headers = request.to_header()
187 req = Request(url, pdata, headers)
188- try:
189- urlopen(req)
190- except HTTPError, e:
191- reactor.callFromThread(deferred.errback, Failure(e))
192-
193- reactor.callFromThread(deferred.callback, None)
194+ urlopen(req)
195
196 def _run(self):
197 """Do the actual running."""
198 if self.use_http:
199 # External user, do the HTTP REST method
200- deferred = defer.Deferred()
201- d = threads.deferToThread(self._create_share_http,
202+ return threads.deferToThread(self._create_share_http,
203 self.node_id, self.share_to,
204- self.name, self.access_level != 'Modify',
205- deferred)
206- d.addErrback(deferred.errback)
207- return deferred
208+ self.name, self.access_level != 'Modify')
209 else:
210 return self.action_queue.client.create_share(self.node_id,
211 self.share_to,
212@@ -2085,9 +2080,12 @@
213
214 url = "https://one.ubuntu.com/files/api/set_public/%s" % (node_key,)
215 method = oauth.OAuthSignatureMethod_PLAINTEXT()
216+ timestamp = timestamp_checker.get_faithful_time()
217+ parameters = {"oauth_timestamp": timestamp}
218 request = oauth.OAuthRequest.from_consumer_and_token(
219 http_url=url,
220 http_method="POST",
221+ parameters=parameters,
222 oauth_consumer=self.action_queue.consumer,
223 token=self.action_queue.token)
224 request.sign_request(method, self.action_queue.consumer,
225@@ -2137,9 +2135,12 @@
226 """Get public files list using the HTTP Web API method."""
227
228 method = oauth.OAuthSignatureMethod_PLAINTEXT()
229+ timestamp = timestamp_checker.get_faithful_time()
230+ parameters = {"oauth_timestamp": timestamp}
231 request = oauth.OAuthRequest.from_consumer_and_token(
232 http_url=self._url,
233 http_method="GET",
234+ parameters=parameters,
235 oauth_consumer=self.action_queue.consumer,
236 token=self.action_queue.token)
237 request.sign_request(method, self.action_queue.consumer,

Subscribers

People subscribed via source and target branches