Merge lp:~facundo/magicicada-protocol/xenial-tests into lp:magicicada-protocol

Proposed by Facundo Batista
Status: Merged
Approved by: Natalia Bidart
Approved revision: 168
Merged at revision: 167
Proposed branch: lp:~facundo/magicicada-protocol/xenial-tests
Merge into: lp:magicicada-protocol
Diff against target: 480 lines (+124/-83)
12 files modified
run-tests (+2/-2)
samples/easy_client.py (+3/-2)
samples/ping_client.py (+3/-3)
setup.py (+0/-2)
tests/certs/cert1.pem (+29/-0)
tests/certs/cert2.pem (+25/-0)
tests/test_client.py (+47/-38)
tests/test_context.py (+3/-27)
tests/test_proxy_tunnel.py (+1/-1)
ubuntuone/storageprotocol/client.py (+5/-5)
ubuntuone/storageprotocol/content_hash.py (+5/-1)
ubuntuone/storageprotocol/request.py (+1/-2)
To merge this branch: bzr merge lp:~facundo/magicicada-protocol/xenial-tests
Reviewer Review Type Date Requested Status
Natalia Bidart Approve
Review via email: mp+306051@code.launchpad.net

Commit message

Small changes for tests to run ok under xenial.

Description of the change

Small changes for tests to run ok under xenial.

Including:

- removed two tests that checked situations after having a protobuf message with an invalid value, and this is not possible anymore in modern protobuf (can not create the request itself, because of internal verifications at creation time).

- Stop patching the certificates loader, just set the proper env var in the test and use regular code. Also included the certificates in the project (previously they were being taken from SSO).

- Lot of aesthetic small details

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

Looks good! Thanks

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'run-tests'
--- run-tests 2014-02-24 18:38:33 +0000
+++ run-tests 2016-09-19 02:06:21 +0000
@@ -21,11 +21,11 @@
2121
22/usr/bin/env python setup.py build22/usr/bin/env python setup.py build
23# run the tests with pure python protobuf23# run the tests with pure python protobuf
24PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python u1trial tests24SSL_CERTIFICATES_DIR=tests/certs PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python u1trial tests
25if [ "$SYSNAME" != "Darwin" ]; then25if [ "$SYSNAME" != "Darwin" ]; then
26 # and with the cpp extension, for server (linux) only:26 # and with the cpp extension, for server (linux) only:
27 if [ $PROTOC_VERSION_AS_INT -lt 2500 ]; then27 if [ $PROTOC_VERSION_AS_INT -lt 2500 ]; then
28 PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=cpp u1trial tests28 SSL_CERTIFICATES_DIR=tests/certs PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=cpp u1trial tests
29 fi29 fi
30fi30fi
3131
3232
=== modified file 'samples/easy_client.py'
--- samples/easy_client.py 2012-03-29 20:28:09 +0000
+++ samples/easy_client.py 2016-09-19 02:06:21 +0000
@@ -256,8 +256,9 @@
256 return failure256 return failure
257257
258258
259# deferred utilities259def skip_result(_, f, *args, **kwargs):
260skip_result = lambda _, f, *args, **kwargs: f(*args, **kwargs)260 """Deferred utilities."""
261 return f(*args, **kwargs)
261262
262263
263def sr_result(result, f, *args, **kwargs):264def sr_result(result, f, *args, **kwargs):
264265
=== modified file 'samples/ping_client.py'
--- samples/ping_client.py 2012-03-29 20:28:09 +0000
+++ samples/ping_client.py 2016-09-19 02:06:21 +0000
@@ -82,12 +82,12 @@
82 reactor.connectTCP('75.101.137.174', 80, PingClientFactory())82 reactor.connectTCP('75.101.137.174', 80, PingClientFactory())
8383
84 # using ssl84 # using ssl
85 #reactor.connectSSL('localhost', 20101, StorageClientFactory(),85 # reactor.connectSSL('localhost', 20101, StorageClientFactory(),
86 # ssl.ClientContextFactory())86 # ssl.ClientContextFactory())
8787
88 # using ssl over a proxy88 # using ssl over a proxy
89 #from ubuntuone.storageprotocol import proxy_tunnel89 # from ubuntuone.storageprotocol import proxy_tunnel
90 #proxy_tunnel.connectHTTPS('localhost', 3128,90 # proxy_tunnel.connectHTTPS('localhost', 3128,
91 # 'localhost', 20101, StorageClientFactory(),91 # 'localhost', 20101, StorageClientFactory(),
92 # user="test", passwd="test")92 # user="test", passwd="test")
9393
9494
=== modified file 'setup.py'
--- setup.py 2013-05-28 22:07:40 +0000
+++ setup.py 2016-09-19 02:06:21 +0000
@@ -21,8 +21,6 @@
21import sys21import sys
22import subprocess22import subprocess
2323
24sys.path.insert(0, os.path.abspath("."))
25
26from distutils.core import setup24from distutils.core import setup
27from distutils.spawn import find_executable25from distutils.spawn import find_executable
28from distutils.command import clean, build26from distutils.command import clean, build
2927
=== added directory 'tests/certs'
=== added file 'tests/certs/cert1.pem'
--- tests/certs/cert1.pem 1970-01-01 00:00:00 +0000
+++ tests/certs/cert1.pem 2016-09-19 02:06:21 +0000
@@ -0,0 +1,29 @@
1-----BEGIN CERTIFICATE-----
2MIIE3jCCA8agAwIBAgICAwEwDQYJKoZIhvcNAQEFBQAwYzELMAkGA1UEBhMCVVMx
3ITAfBgNVBAoTGFRoZSBHbyBEYWRkeSBHcm91cCwgSW5jLjExMC8GA1UECxMoR28g
4RGFkZHkgQ2xhc3MgMiBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTAeFw0wNjExMTYw
5MTU0MzdaFw0yNjExMTYwMTU0MzdaMIHKMQswCQYDVQQGEwJVUzEQMA4GA1UECBMH
6QXJpem9uYTETMBEGA1UEBxMKU2NvdHRzZGFsZTEaMBgGA1UEChMRR29EYWRkeS5j
7b20sIEluYy4xMzAxBgNVBAsTKmh0dHA6Ly9jZXJ0aWZpY2F0ZXMuZ29kYWRkeS5j
8b20vcmVwb3NpdG9yeTEwMC4GA1UEAxMnR28gRGFkZHkgU2VjdXJlIENlcnRpZmlj
9YXRpb24gQXV0aG9yaXR5MREwDwYDVQQFEwgwNzk2OTI4NzCCASIwDQYJKoZIhvcN
10AQEBBQADggEPADCCAQoCggEBAMQt1RWMnCZM7DI161+4WQFapmGBWTtwY6vj3D3H
11KrjJM9N55DrtPDAjhI6zMBS2sofDPZVUBJ7fmd0LJR4h3mUpfjWoqVTr9vcyOdQm
12VZWt7/v+WIbXnvQAjYwqDL1CBM6nPwT27oDyqu9SoWlm2r4arV3aLGbqGmu75RpR
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j
18YXRpb24gQXV0aG9yaXR5ggEAMAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEF
19BQADggEBADJL87LKPpH8EsahB4yOd6AzBhRckB4Y9wimPQoZ+YeAEW5p5JYX
20MP80kWNyOO7MHAGjHZQopDH2esRU1/blMVgDoszOYtuURXO1v0XJJLXVggKt
21I3lpjbi2Tc7PTMozI+gciKqdi0FuFskg5YmezTvacPd+mSYgFFQlq25zheab
22IZ0KbIIOqPjCDPoQHmyW74cNxA9hi63ugyuV+I6ShHI56yDqg+2DzZduCLzr
23Tia2cyvk0/ZM/iZx4mERdEr/VxqHD3VILs9RaRegAhJhldXRQLIQTO7ErBBD
24pqWeCtWVYpoNz4iCxTIM5CufReYNnyicsbkqWletNw+vHX/bvZ8=
25-----END CERTIFICATE-----
026
=== modified file 'tests/test_client.py'
--- tests/test_client.py 2015-05-18 17:23:03 +0000
+++ tests/test_client.py 2016-09-19 02:06:21 +0000
@@ -135,6 +135,10 @@
135 message.share.access_level = 0135 message.share.access_level = 0
136136
137137
138def noop_callback(*a):
139 """No op callback."""
140
141
138class MethodMock(object):142class MethodMock(object):
139 """A class to overwrite methods to know if they were called.143 """A class to overwrite methods to know if they were called.
140144
@@ -258,9 +262,8 @@
258262
259 def test_set_volume_deleted_callback(self):263 def test_set_volume_deleted_callback(self):
260 """Test callback setting."""264 """Test callback setting."""
261 a_callback = lambda x: None265 self.client.set_volume_deleted_callback(noop_callback)
262 self.client.set_volume_deleted_callback(a_callback)266 self.assertTrue(self.client._volume_deleted_callback is noop_callback)
263 self.assertTrue(self.client._volume_deleted_callback is a_callback)
264267
265 def test_callback_must_be_callable(self):268 def test_callback_must_be_callable(self):
266 """Test set callback parameters."""269 """Test set callback parameters."""
@@ -275,31 +278,33 @@
275278
276 def test_set_volume_created_callback(self):279 def test_set_volume_created_callback(self):
277 """Test callback setting."""280 """Test callback setting."""
278 a_callback = lambda y, z: None281 self.client.set_volume_created_callback(noop_callback)
279 self.client.set_volume_created_callback(a_callback)282 self.assertIs(self.client._volume_created_callback, noop_callback)
280 self.assertTrue(self.client._volume_created_callback is a_callback)
281283
282 def test_set_volume_new_generation_callback(self):284 def test_set_volume_new_generation_callback(self):
283 """Test callback setting."""285 """Test callback setting."""
284 cback = lambda y, z: None286 self.client.set_volume_new_generation_callback(noop_callback)
285 self.client.set_volume_new_generation_callback(cback)287 self.assertIs(self.client._volume_new_generation_callback,
286 self.assertTrue(self.client._volume_new_generation_callback is cback)288 noop_callback)
287289
288 # share notification callbacks290 # share notification callbacks
289 def test_share_change_callback(self):291 def test_share_change_callback(self):
290 """Test share_change callback usage."""292 """Test share_change callback usage."""
291 self.assertRaises(TypeError, self.client.set_share_change_callback,293 self.assertRaises(TypeError, self.client.set_share_change_callback,
292 'hello')294 'hello')
293 #create a response and message295 # create a response and message
294 share_resp = sharersp.NotifyShareHolder.from_params(296 share_resp = sharersp.NotifyShareHolder.from_params(
295 uuid.uuid4(), uuid.uuid4(), 'sname', 'byu', 'tou', 'View')297 uuid.uuid4(), uuid.uuid4(), 'sname', 'byu', 'tou', 'View')
296 proto_msg = protocol_pb2.Message()298 proto_msg = protocol_pb2.Message()
297 proto_msg.type = protocol_pb2.Message.NOTIFY_SHARE299 proto_msg.type = protocol_pb2.Message.NOTIFY_SHARE
298 share_resp.dump_to_msg(proto_msg.notify_share)300 share_resp.dump_to_msg(proto_msg.notify_share)
299301
300 #wire up a call back and make sure it's correct302 # wire up a call back and make sure it's correct
301 self.share_notif = None303 self.share_notif = None
302 a_callback = lambda notif: setattr(self, 'share_notif', notif)304
305 def a_callback(notif):
306 setattr(self, 'share_notif', notif)
307
303 self.client.set_share_change_callback(a_callback)308 self.client.set_share_change_callback(a_callback)
304 self.assertTrue(self.client._share_change_callback is a_callback)309 self.assertTrue(self.client._share_change_callback is a_callback)
305 self.client.handle_NOTIFY_SHARE(proto_msg)310 self.client.handle_NOTIFY_SHARE(proto_msg)
@@ -315,9 +320,12 @@
315 proto_msg.type = protocol_pb2.Message.SHARE_DELETED320 proto_msg.type = protocol_pb2.Message.SHARE_DELETED
316 proto_msg.share_deleted.share_id = str(share_id)321 proto_msg.share_deleted.share_id = str(share_id)
317322
318 #wire up a call back and make sure it's correct323 # wire up a call back and make sure it's correct
319 self.deleted_share_id = None324 self.deleted_share_id = None
320 a_callback = lambda notif: setattr(self, 'deleted_share_id', notif)325
326 def a_callback(notif):
327 setattr(self, 'deleted_share_id', notif)
328
321 self.client.set_share_delete_callback(a_callback)329 self.client.set_share_delete_callback(a_callback)
322 self.assertTrue(self.client._share_delete_callback is a_callback)330 self.assertTrue(self.client._share_delete_callback is a_callback)
323 self.client.handle_SHARE_DELETED(proto_msg)331 self.client.handle_SHARE_DELETED(proto_msg)
@@ -334,9 +342,12 @@
334 proto_msg.share_accepted.share_id = str(share_id)342 proto_msg.share_accepted.share_id = str(share_id)
335 proto_msg.share_accepted.answer = protocol_pb2.ShareAccepted.YES343 proto_msg.share_accepted.answer = protocol_pb2.ShareAccepted.YES
336344
337 #wire up a call back and make sure it's correct345 # wire up a call back and make sure it's correct
338 self.answer = None346 self.answer = None
339 a_callback = lambda s, a: setattr(self, 'answer', (s, a))347
348 def a_callback(s, a):
349 setattr(self, 'answer', (s, a))
350
340 self.client.set_share_answer_callback(a_callback)351 self.client.set_share_answer_callback(a_callback)
341 self.assertTrue(self.client._share_answer_callback is a_callback)352 self.assertTrue(self.client._share_answer_callback is a_callback)
342 self.client.handle_SHARE_ACCEPTED(proto_msg)353 self.client.handle_SHARE_ACCEPTED(proto_msg)
@@ -347,8 +358,8 @@
347 """Test handle_VOLUME_NEW_GENERATION with an uuid id."""358 """Test handle_VOLUME_NEW_GENERATION with an uuid id."""
348 # set the callback to record the info359 # set the callback to record the info
349 called = []360 called = []
350 f = lambda *a: called.append(a)361 self.client.set_volume_new_generation_callback(
351 self.client.set_volume_new_generation_callback(f)362 lambda *a: called.append(a))
352363
353 # create the message364 # create the message
354 message = protocol_pb2.Message()365 message = protocol_pb2.Message()
@@ -365,8 +376,8 @@
365 """Test handle_VOLUME_NEW_GENERATION for ROOT."""376 """Test handle_VOLUME_NEW_GENERATION for ROOT."""
366 # set the callback to record the info377 # set the callback to record the info
367 called = []378 called = []
368 f = lambda *a: called.append(a)379 self.client.set_volume_new_generation_callback(
369 self.client.set_volume_new_generation_callback(f)380 lambda *a: called.append(a))
370381
371 # create the message382 # create the message
372 message = protocol_pb2.Message()383 message = protocol_pb2.Message()
@@ -393,7 +404,10 @@
393 def test_handle_root_created_passes_a_root(self):404 def test_handle_root_created_passes_a_root(self):
394 """Test handle_VOLUME_CREATED parameter passing."""405 """Test handle_VOLUME_CREATED parameter passing."""
395 self.volume = None406 self.volume = None
396 a_callback = lambda vol: setattr(self, 'volume', vol)407
408 def a_callback(vol):
409 setattr(self, 'volume', vol)
410
397 self.client.set_volume_created_callback(a_callback)411 self.client.set_volume_created_callback(a_callback)
398412
399 message = build_volume_created()413 message = build_volume_created()
@@ -406,7 +420,10 @@
406 def test_handle_udf_created_passes_a_udf(self):420 def test_handle_udf_created_passes_a_udf(self):
407 """Test handle_VOLUME_CREATED parameter passing."""421 """Test handle_VOLUME_CREATED parameter passing."""
408 self.volume = None422 self.volume = None
409 a_callback = lambda vol: setattr(self, 'volume', vol)423
424 def a_callback(vol):
425 setattr(self, 'volume', vol)
426
410 self.client.set_volume_created_callback(a_callback)427 self.client.set_volume_created_callback(a_callback)
411428
412 message = build_volume_created()429 message = build_volume_created()
@@ -419,7 +436,10 @@
419 def test_handle_share_created_passes_a_share(self):436 def test_handle_share_created_passes_a_share(self):
420 """Test handle_VOLUME_CREATED parameter passing."""437 """Test handle_VOLUME_CREATED parameter passing."""
421 self.volume = None438 self.volume = None
422 a_callback = lambda vol: setattr(self, 'volume', vol)439
440 def a_callback(vol):
441 setattr(self, 'volume', vol)
442
423 self.client.set_volume_created_callback(a_callback)443 self.client.set_volume_created_callback(a_callback)
424444
425 message = build_volume_created()445 message = build_volume_created()
@@ -429,14 +449,6 @@
429 self.client.handle_VOLUME_CREATED(message)449 self.client.handle_VOLUME_CREATED(message)
430 self.assertEquals(share, self.volume)450 self.assertEquals(share, self.volume)
431451
432 def test_handle_volume_created_if_volume_is_buggy(self):
433 """Test handle_VOLUME_CREATED if the volume is buggy."""
434 message = build_volume_created()
435 message.volume_created.type = -1 # invalid type!
436 self.client.set_volume_created_callback(lambda vol: None)
437 self.assertRaises(TypeError, self.client.handle_VOLUME_CREATED,
438 message)
439
440 def test_handle_volume_created_if_callback_is_none(self):452 def test_handle_volume_created_if_callback_is_none(self):
441 """Test handle_VOLUME_CREATED if callback is none."""453 """Test handle_VOLUME_CREATED if callback is none."""
442 message = build_volume_created()454 message = build_volume_created()
@@ -456,7 +468,10 @@
456 def test_handle_volume_deleted_passes_the_id(self):468 def test_handle_volume_deleted_passes_the_id(self):
457 """Test handle_VOLUME_DELETED."""469 """Test handle_VOLUME_DELETED."""
458 self.volume = None470 self.volume = None
459 a_callback = lambda vol_id: setattr(self, 'volume', vol_id)471
472 def a_callback(vol):
473 setattr(self, 'volume', vol)
474
460 self.client.set_volume_deleted_callback(a_callback)475 self.client.set_volume_deleted_callback(a_callback)
461476
462 message = build_volume_deleted()477 message = build_volume_deleted()
@@ -566,12 +581,6 @@
566 message = protocol_pb2.Message()581 message = protocol_pb2.Message()
567 self.assertRaises(FakedError, self.request.processMessage, message)582 self.assertRaises(FakedError, self.request.processMessage, message)
568583
569 def test_process_message_error_when_incorrect_volume(self):
570 """Test error condition when incorrect volume type."""
571 message = build_list_volumes()
572 message.list_volumes.type = -1
573 self.assertRaises(FakedError, self.request.processMessage, message)
574
575 def test_process_message_volume_created(self):584 def test_process_message_volume_created(self):
576 """Test request processMessage on sucess."""585 """Test request processMessage on sucess."""
577 message = build_list_volumes()586 message = build_list_volumes()
578587
=== modified file 'tests/test_context.py'
--- tests/test_context.py 2015-05-18 17:23:03 +0000
+++ tests/test_context.py 2016-09-19 02:06:21 +0000
@@ -36,12 +36,6 @@
3636
37from ubuntuone.storageprotocol import context37from ubuntuone.storageprotocol import context
3838
39try:
40 from ubuntu_sso.utils import get_cert_dir
41except ImportError:
42 # old system, let's support Precise
43 get_cert_dir = lambda: '/etc/ssl/certs'
44
4539
46class FakeCerts(object):40class FakeCerts(object):
47 """CA and Server certificate."""41 """CA and Server certificate."""
@@ -123,24 +117,6 @@
123 """Tests for the context.get_ssl_context function."""117 """Tests for the context.get_ssl_context function."""
124118
125 @defer.inlineCallbacks119 @defer.inlineCallbacks
126 def setUp(self):
127 yield super(SSLContextTestCase, self).setUp()
128 self.patch(context, "get_certificates", self.get_certificates)
129
130 def get_certificates(self):
131 """Get the uninstalled certificates, for testing."""
132 certs = []
133 data_dir = get_cert_dir()
134
135 for certname in ['UbuntuOne-Go_Daddy_Class_2_CA.pem',
136 'UbuntuOne-Go_Daddy_CA.pem']:
137 cert_path = os.path.abspath(os.path.join(data_dir, certname))
138 c = ssl.Certificate.loadPEM(file(cert_path, 'r').read())
139 certs.append(c.original)
140
141 return certs
142
143 @defer.inlineCallbacks
144 def verify_context(self, server_context, client_context):120 def verify_context(self, server_context, client_context):
145 """Verify a client context with a given server context."""121 """Verify a client context with a given server context."""
146 site = server.Site(FakeResource())122 site = server.Site(FakeResource())
@@ -177,7 +153,7 @@
177153
178 d = self.verify_context(server_context, client_context)154 d = self.verify_context(server_context, client_context)
179 e = yield self.assertFailure(d, SSL.Error)155 e = yield self.assertFailure(d, SSL.Error)
180 self.assertEqual(e[0][0][1], "SSL3_GET_SERVER_CERTIFICATE")156 self.assertEqual(e[0][0][1], "ssl3_get_server_certificate")
181157
182 @defer.inlineCallbacks158 @defer.inlineCallbacks
183 def test_fails_hostname(self):159 def test_fails_hostname(self):
@@ -191,7 +167,7 @@
191167
192 d = self.verify_context(server_context, client_context)168 d = self.verify_context(server_context, client_context)
193 e = yield self.assertFailure(d, SSL.Error)169 e = yield self.assertFailure(d, SSL.Error)
194 self.assertEqual(e[0][0][1], "SSL3_GET_SERVER_CERTIFICATE")170 self.assertEqual(e[0][0][1], "ssl3_get_server_certificate")
195171
196 @defer.inlineCallbacks172 @defer.inlineCallbacks
197 def test_matches_all(self):173 def test_matches_all(self):
@@ -212,7 +188,7 @@
212 def test_load_all_certificates(self):188 def test_load_all_certificates(self):
213 """Load all available certificates."""189 """Load all available certificates."""
214 certs = FakeCerts(self, "localhost")190 certs = FakeCerts(self, "localhost")
215 self.patch(context, 'get_cert_dir', lambda: certs.cert_dir)191 os.environ['SSL_CERTIFICATES_DIR'] = certs.cert_dir
216 # remove the key192 # remove the key
217 os.unlink(certs.server_key_path)193 os.unlink(certs.server_key_path)
218 loaded = context.get_certificates()194 loaded = context.get_certificates()
219195
=== modified file 'tests/test_proxy_tunnel.py'
--- tests/test_proxy_tunnel.py 2012-03-29 20:28:09 +0000
+++ tests/test_proxy_tunnel.py 2016-09-19 02:06:21 +0000
@@ -135,7 +135,7 @@
135 if auth is not None:135 if auth is not None:
136 auth_line = "Proxy-Authorization: Basic " + \136 auth_line = "Proxy-Authorization: Basic " + \
137 base64.b64encode("test:test")137 base64.b64encode("test:test")
138 if not auth_line in data:138 if auth_line not in data:
139 proto.dataReceived("HTTP/1.0 403 Forbidden\r\n\r\n")139 proto.dataReceived("HTTP/1.0 403 Forbidden\r\n\r\n")
140 else:140 else:
141 proto.dataReceived(response_string)141 proto.dataReceived(response_string)
142142
=== modified file 'ubuntuone/storageprotocol/client.py'
--- ubuntuone/storageprotocol/client.py 2015-05-18 17:23:03 +0000
+++ ubuntuone/storageprotocol/client.py 2016-09-19 02:06:21 +0000
@@ -1689,8 +1689,8 @@
1689 """1689 """
1690 delayed_call = getattr(self, call_id)1690 delayed_call = getattr(self, call_id)
1691 # check if we already have a DelayedCall running1691 # check if we already have a DelayedCall running
1692 if delayed_call is None or (not delayed_call.active()1692 if delayed_call is None or (
1693 and delayed_call.cancelled):1693 not delayed_call.active() and delayed_call.cancelled):
1694 return self.callLater(period, func)1694 return self.callLater(period, func)
1695 return delayed_call1695 return delayed_call
16961696
@@ -1837,12 +1837,12 @@
1837 reactor.connectTCP('localhost', 20100, StorageClientFactory())1837 reactor.connectTCP('localhost', 20100, StorageClientFactory())
18381838
1839 # using ssl1839 # using ssl
1840 #reactor.connectSSL('localhost', 20101, StorageClientFactory(),1840 # reactor.connectSSL('localhost', 20101, StorageClientFactory(),
1841 # ssl.ClientContextFactory())1841 # ssl.ClientContextFactory())
18421842
1843 # using ssl over a proxy1843 # using ssl over a proxy
1844 #from ubuntuone.storageprotocol import proxy_tunnel1844 # from ubuntuone.storageprotocol import proxy_tunnel
1845 #proxy_tunnel.connectHTTPS('localhost', 3128,1845 # proxy_tunnel.connectHTTPS('localhost', 3128,
1846 # 'localhost', 20101, StorageClientFactory(),1846 # 'localhost', 20101, StorageClientFactory(),
1847 # user="test", passwd="test")1847 # user="test", passwd="test")
18481848
18491849
=== modified file 'ubuntuone/storageprotocol/content_hash.py'
--- ubuntuone/storageprotocol/content_hash.py 2012-03-29 20:28:09 +0000
+++ ubuntuone/storageprotocol/content_hash.py 2016-09-19 02:06:21 +0000
@@ -36,6 +36,10 @@
36import zlib36import zlib
3737
3838
39def noop():
40 """No op."""
41
42
39class ContentHash(object):43class ContentHash(object):
40 """Encapsulate the generation of content hashes.44 """Encapsulate the generation of content hashes.
4145
@@ -43,7 +47,7 @@
43 composition to get similar methods.47 composition to get similar methods.
4448
45 """49 """
46 method = lambda: None50 method = noop
47 method_name = ""51 method_name = ""
4852
49 def __init__(self):53 def __init__(self):
5054
=== modified file 'ubuntuone/storageprotocol/request.py'
--- ubuntuone/storageprotocol/request.py 2013-08-01 21:32:53 +0000
+++ ubuntuone/storageprotocol/request.py 2016-09-19 02:06:21 +0000
@@ -214,8 +214,7 @@
214214
215 if is_invalid:215 if is_invalid:
216 self.log.error("Validation error: " + ", ".join(is_invalid))216 self.log.error("Validation error: " + ", ".join(is_invalid))
217 comment = ("Validation error:\n"217 comment = "Validation error:\n" + "\n".join(is_invalid)
218 + "\n".join(is_invalid))
219 if len(comment) > MAX_PAYLOAD_SIZE - 100:218 if len(comment) > MAX_PAYLOAD_SIZE - 100:
220 comment = comment[:MAX_PAYLOAD_SIZE - 112] + ' [truncated]'219 comment = comment[:MAX_PAYLOAD_SIZE - 112] + ' [truncated]'
221 error_message = protocol_pb2.Message()220 error_message = protocol_pb2.Message()

Subscribers

People subscribed via source and target branches

to all changes: