Merge lp:~nataliabidart/magicicada-protocol/update-copyright-headers into lp:magicicada-protocol

Proposed by Natalia Bidart
Status: Merged
Approved by: Natalia Bidart
Approved revision: 170
Merged at revision: 170
Proposed branch: lp:~nataliabidart/magicicada-protocol/update-copyright-headers
Merge into: lp:magicicada-protocol
Diff against target: 1468 lines (+175/-254)
36 files modified
run-tests (+2/-2)
samples/easy_client.py (+12/-14)
samples/ping_client.py (+4/-7)
ubuntuone/__init__.py (+5/-2)
ubuntuone/storageprotocol/__init__.py (+3/-1)
ubuntuone/storageprotocol/client.py (+5/-13)
ubuntuone/storageprotocol/content_hash.py (+3/-4)
ubuntuone/storageprotocol/context.py (+5/-4)
ubuntuone/storageprotocol/delta.py (+8/-9)
ubuntuone/storageprotocol/dircontent.proto (+1/-2)
ubuntuone/storageprotocol/dircontent.py (+3/-6)
ubuntuone/storageprotocol/errors.py (+4/-5)
ubuntuone/storageprotocol/protocol.proto (+1/-1)
ubuntuone/storageprotocol/proxy_tunnel.py (+9/-10)
ubuntuone/storageprotocol/public_file_info.py (+3/-1)
ubuntuone/storageprotocol/request.py (+9/-18)
ubuntuone/storageprotocol/sharersp.py (+3/-7)
ubuntuone/storageprotocol/tests/__init__.py (+3/-3)
ubuntuone/storageprotocol/tests/test_bytesproducer.py (+5/-7)
ubuntuone/storageprotocol/tests/test_client.py (+7/-11)
ubuntuone/storageprotocol/tests/test_context.py (+15/-10)
ubuntuone/storageprotocol/tests/test_delta_info.py (+2/-2)
ubuntuone/storageprotocol/tests/test_dircontent.py (+3/-4)
ubuntuone/storageprotocol/tests/test_errors.py (+7/-13)
ubuntuone/storageprotocol/tests/test_hashes.py (+4/-13)
ubuntuone/storageprotocol/tests/test_proxy_tunnel.py (+7/-15)
ubuntuone/storageprotocol/tests/test_public_file_info.py (+2/-2)
ubuntuone/storageprotocol/tests/test_putcontent.py (+4/-6)
ubuntuone/storageprotocol/tests/test_query.py (+7/-10)
ubuntuone/storageprotocol/tests/test_request.py (+5/-11)
ubuntuone/storageprotocol/tests/test_sharersp.py (+5/-5)
ubuntuone/storageprotocol/tests/test_throttling.py (+5/-8)
ubuntuone/storageprotocol/tests/test_volumes.py (+3/-14)
ubuntuone/storageprotocol/utils.py (+3/-3)
ubuntuone/storageprotocol/validators.py (+6/-7)
ubuntuone/storageprotocol/volumes.py (+2/-4)
To merge this branch: bzr merge lp:~nataliabidart/magicicada-protocol/update-copyright-headers
Reviewer Review Type Date Requested Status
Natalia Bidart Approve
Review via email: mp+342841@code.launchpad.net

Commit message

- Added proper copyright notices and coding headers.

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

Trivial.

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 2016-09-18 23:26:42 +0000
+++ run-tests 2018-04-08 19:37:28 +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
24SSL_CERTIFICATES_DIR=tests/certs PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python u1trial tests24SSL_CERTIFICATES_DIR=ubuntuone/storageprotocol/tests/certs PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python u1trial ubuntuone/storageprotocol/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 SSL_CERTIFICATES_DIR=tests/certs PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=cpp u1trial tests28 SSL_CERTIFICATES_DIR=ubuntuone/storageprotocol/tests/certs PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=cpp u1trial ubuntuone/storageprotocol/tests
29 fi29 fi
30fi30fi
3131
3232
=== modified file 'samples/easy_client.py'
--- samples/easy_client.py 2016-09-19 02:00:32 +0000
+++ samples/easy_client.py 2018-04-08 19:37:28 +0000
@@ -1,8 +1,7 @@
1# ubuntuone.storageprotocol.samples.easy_client - a simple client1# -*- coding: utf-8 -*-
2#
3# Author: Lucio Torre <lucio.torre@canonical.com>
4#2#
5# Copyright 2009-2012 Canonical Ltd.3# Copyright 2009-2012 Canonical Ltd.
4# Copyright 2015-2018 Chicharreros (https://launchpad.net/~chicharreros)
6#5#
7# This program is free software: you can redistribute it and/or modify it6# This program is free software: you can redistribute it and/or modify it
8# under the terms of the GNU Affero General Public License version 3,7# under the terms of the GNU Affero General Public License version 3,
@@ -28,8 +27,9 @@
28# do not wish to do so, delete this exception statement from your27# do not wish to do so, delete this exception statement from your
29# version. If you delete this exception statement from all source28# version. If you delete this exception statement from all source
30# files in the program, then also delete it here.29# files in the program, then also delete it here.
31"""A simple client with some tests30
32"""31"""A simple client with some tests."""
32
33import os33import os
34import time34import time
35import math35import math
@@ -41,8 +41,8 @@
41from ubuntuone.storageprotocol.client import (41from ubuntuone.storageprotocol.client import (
42 StorageClientFactory, StorageClient)42 StorageClientFactory, StorageClient)
43from ubuntuone.storageprotocol import request, protocol_pb243from ubuntuone.storageprotocol import request, protocol_pb2
44from ubuntuone.storageprotocol.dircontent_pb2 import \44from ubuntuone.storageprotocol.dircontent_pb2 import (
45 DirectoryContent, DIRECTORY45 DirectoryContent, DIRECTORY)
4646
4747
48class NotDirectory(Exception):48class NotDirectory(Exception):
@@ -51,8 +51,7 @@
5151
52def delay_time(step):52def delay_time(step):
53 """generates a delay for each step"""53 """generates a delay for each step"""
54 return (((math.exp(step) - 1) / 10) /54 return ((math.exp(step) - 1) / 10) / (1 + random.random())
55 (1 + random.random()))
5655
5756
58def retry(function):57def retry(function):
@@ -91,7 +90,6 @@
9190
92 def connectionMade(self):91 def connectionMade(self):
93 """Setup and call callback."""92 """Setup and call callback."""
94 # pylint: disable=W0201
95 StorageClient.connectionMade(self)93 StorageClient.connectionMade(self)
96 self.factory.clientConnectionMade(self)94 self.factory.clientConnectionMade(self)
9795
@@ -158,15 +156,15 @@
158 def mkfile(self, name):156 def mkfile(self, name):
159 """make a file named name in cwd."""157 """make a file named name in cwd."""
160 d = self.get_cwd_id()158 d = self.get_cwd_id()
161 d.addCallback(lambda _:159 d.addCallback(
162 self.make_file(request.ROOT, self.cwd_id, name))160 lambda _: self.make_file(request.ROOT, self.cwd_id, name))
163 return d161 return d
164162
165 def mkdir(self, name):163 def mkdir(self, name):
166 """make a dir named name in cwd."""164 """make a dir named name in cwd."""
167 d = self.get_cwd_id()165 d = self.get_cwd_id()
168 d.addCallback(lambda _:166 d.addCallback(
169 self.make_dir(request.ROOT, self.cwd_id, name))167 lambda _: self.make_dir(request.ROOT, self.cwd_id, name))
170 return d168 return d
171169
172 def put(self, name, content):170 def put(self, name, content):
173171
=== modified file 'samples/ping_client.py'
--- samples/ping_client.py 2016-09-19 02:00:32 +0000
+++ samples/ping_client.py 2018-04-08 19:37:28 +0000
@@ -1,8 +1,7 @@
1# ubuntuone.storageprotocol.samples.ping_client - a ping client1# -*- coding: utf-8 -*-
2#
3# Author: Lucio Torre <lucio.torre@canonical.com>
4#2#
5# Copyright 2009-2012 Canonical Ltd.3# Copyright 2009-2012 Canonical Ltd.
4# Copyright 2015-2018 Chicharreros (https://launchpad.net/~chicharreros)
6#5#
7# This program is free software: you can redistribute it and/or modify it6# This program is free software: you can redistribute it and/or modify it
8# under the terms of the GNU Affero General Public License version 3,7# under the terms of the GNU Affero General Public License version 3,
@@ -28,8 +27,8 @@
28# do not wish to do so, delete this exception statement from your27# do not wish to do so, delete this exception statement from your
29# version. If you delete this exception statement from all source28# version. If you delete this exception statement from all source
30# files in the program, then also delete it here.29# files in the program, then also delete it here.
31"""A simple ping client30
32"""31"""A simple ping client."""
3332
34from twisted.internet import reactor33from twisted.internet import reactor
3534
@@ -42,7 +41,6 @@
4241
43 def connectionMade(self):42 def connectionMade(self):
44 """Setup and call callback."""43 """Setup and call callback."""
45 # pylint: disable=W0201
46 StorageClient.connectionMade(self)44 StorageClient.connectionMade(self)
47 print "Connection made."45 print "Connection made."
48 d = self.ping()46 d = self.ping()
@@ -63,7 +61,6 @@
6361
64class PingClientFactory(StorageClientFactory):62class PingClientFactory(StorageClientFactory):
65 """A test oriented protocol factory."""63 """A test oriented protocol factory."""
66 # no init: pylint: disable=W0232
6764
68 protocol = PingClient65 protocol = PingClient
6966
7067
=== modified file 'ubuntuone/__init__.py'
--- ubuntuone/__init__.py 2012-03-29 20:28:09 +0000
+++ ubuntuone/__init__.py 2018-04-08 19:37:28 +0000
@@ -1,6 +1,7 @@
1# __init__.py1# -*- coding: utf-8 -*-
2#2#
3# Copyright 2009-2012 Canonical Ltd.3# Copyright 2009-2012 Canonical Ltd.
4# Copyright 2015-2018 Chicharreros (https://launchpad.net/~chicharreros)
4#5#
5# This program is free software: you can redistribute it and/or modify it6# This program is free software: you can redistribute it and/or modify it
6# under the terms of the GNU Affero General Public License version 3,7# under the terms of the GNU Affero General Public License version 3,
@@ -26,5 +27,7 @@
26# do not wish to do so, delete this exception statement from your27# do not wish to do so, delete this exception statement from your
27# version. If you delete this exception statement from all source28# version. If you delete this exception statement from all source
28# files in the program, then also delete it here.29# files in the program, then also delete it here.
29"""ubuntuone package"""30
31"""ubuntuone package."""
32
30__import__('pkg_resources').declare_namespace(__name__)33__import__('pkg_resources').declare_namespace(__name__)
3134
=== modified file 'ubuntuone/storageprotocol/__init__.py'
--- ubuntuone/storageprotocol/__init__.py 2012-03-29 20:28:09 +0000
+++ ubuntuone/storageprotocol/__init__.py 2018-04-08 19:37:28 +0000
@@ -1,6 +1,7 @@
1# __init__.py1# -*- coding: utf-8 -*-
2#2#
3# Copyright 2009-2012 Canonical Ltd.3# Copyright 2009-2012 Canonical Ltd.
4# Copyright 2015-2018 Chicharreros (https://launchpad.net/~chicharreros)
4#5#
5# This program is free software: you can redistribute it and/or modify it6# This program is free software: you can redistribute it and/or modify it
6# under the terms of the GNU Affero General Public License version 3,7# under the terms of the GNU Affero General Public License version 3,
@@ -26,4 +27,5 @@
26# do not wish to do so, delete this exception statement from your27# do not wish to do so, delete this exception statement from your
27# version. If you delete this exception statement from all source28# version. If you delete this exception statement from all source
28# files in the program, then also delete it here.29# files in the program, then also delete it here.
30
29"""ubuntuone.storageprotocol package."""31"""ubuntuone.storageprotocol package."""
3032
=== modified file 'ubuntuone/storageprotocol/client.py'
--- ubuntuone/storageprotocol/client.py 2016-11-15 23:37:49 +0000
+++ ubuntuone/storageprotocol/client.py 2018-04-08 19:37:28 +0000
@@ -1,5 +1,7 @@
1# -*- coding: utf-8 -*-
2#
1# Copyright 2009-2015 Canonical Ltd.3# Copyright 2009-2015 Canonical Ltd.
2# Copyright 2016 Chicharreros (https://launchpad.net/~chicharreros)4# Copyright 2015-2018 Chicharreros (https://launchpad.net/~chicharreros)
3#5#
4# This program is free software: you can redistribute it and/or modify it6# This program is free software: you can redistribute it and/or modify it
5# under the terms of the GNU Affero General Public License version 3,7# under the terms of the GNU Affero General Public License version 3,
@@ -616,7 +618,6 @@
616618
617 def processMessage(self, message):619 def processMessage(self, message):
618 """Process messages."""620 """Process messages."""
619 # pylint: disable=W0201
620 if message.type == protocol_pb2.Message.NODE_ATTR:621 if message.type == protocol_pb2.Message.NODE_ATTR:
621 if self.node_attr_callback is not None:622 if self.node_attr_callback is not None:
622 self.node_attr_callback(623 self.node_attr_callback(
@@ -667,7 +668,6 @@
667668
668 def _start(self):669 def _start(self):
669 """Send the LIST_SHARES message to the server."""670 """Send the LIST_SHARES message to the server."""
670 # pylint: disable=W0201
671 message = protocol_pb2.Message()671 message = protocol_pb2.Message()
672 message.type = protocol_pb2.Message.LIST_SHARES672 message.type = protocol_pb2.Message.LIST_SHARES
673 self.sendMessage(message)673 self.sendMessage(message)
@@ -935,7 +935,6 @@
935935
936 @ivar new_generation: the generation that the volume is at now936 @ivar new_generation: the generation that the volume is at now
937 """937 """
938 # pylint: disable=C0111
939938
940 __slots__ = ('share', 'node', 'new_generation')939 __slots__ = ('share', 'node', 'new_generation')
941940
@@ -1361,7 +1360,6 @@
13611360
1362 def processMessage(self, message):1361 def processMessage(self, message):
1363 """Handle messages."""1362 """Handle messages."""
1364 # pylint: disable=W0201
1365 if message.type == self.create_response:1363 if message.type == self.create_response:
1366 self.new_id = message.new.node1364 self.new_id = message.new.node
1367 self.new_parent_id = message.new.parent_node1365 self.new_parent_id = message.new.parent_node
@@ -1406,7 +1404,6 @@
14061404
1407 def processMessage(self, message):1405 def processMessage(self, message):
1408 """Handle messages."""1406 """Handle messages."""
1409 # pylint: disable=W0201
1410 if message.type == protocol_pb2.Message.PROTOCOL_VERSION:1407 if message.type == protocol_pb2.Message.PROTOCOL_VERSION:
1411 self.other_protocol_version = message.protocol.version1408 self.other_protocol_version = message.protocol.version
1412 self.done()1409 self.done()
@@ -1520,7 +1517,6 @@
15201517
1521 def _start(self):1518 def _start(self):
1522 """Send the FREE_SPACE_INQUIRY message to the server."""1519 """Send the FREE_SPACE_INQUIRY message to the server."""
1523 # pylint: disable=W0201
1524 message = protocol_pb2.Message()1520 message = protocol_pb2.Message()
1525 message.type = protocol_pb2.Message.FREE_SPACE_INQUIRY1521 message.type = protocol_pb2.Message.FREE_SPACE_INQUIRY
1526 message.free_space_inquiry.share_id = self.share_id1522 message.free_space_inquiry.share_id = self.share_id
@@ -1529,7 +1525,6 @@
15291525
1530 def processMessage(self, message):1526 def processMessage(self, message):
1531 """Process the answer from the server."""1527 """Process the answer from the server."""
1532 # pylint: disable=W0201
1533 if message.type == protocol_pb2.Message.FREE_SPACE_INFO:1528 if message.type == protocol_pb2.Message.FREE_SPACE_INFO:
1534 self.free_bytes = message.free_space_info.free_bytes1529 self.free_bytes = message.free_space_info.free_bytes
1535 self.done()1530 self.done()
@@ -1544,7 +1539,6 @@
15441539
1545 def _start(self):1540 def _start(self):
1546 """Send the FREE_SPACE_INQUIRY message to the server."""1541 """Send the FREE_SPACE_INQUIRY message to the server."""
1547 # pylint: disable=W0201
1548 message = protocol_pb2.Message()1542 message = protocol_pb2.Message()
1549 message.type = protocol_pb2.Message.ACCOUNT_INQUIRY1543 message.type = protocol_pb2.Message.ACCOUNT_INQUIRY
1550 self.sendMessage(message)1544 self.sendMessage(message)
@@ -1552,7 +1546,6 @@
15521546
1553 def processMessage(self, message):1547 def processMessage(self, message):
1554 """Process the answer from the server."""1548 """Process the answer from the server."""
1555 # pylint: disable=W0201
1556 if message.type == protocol_pb2.Message.ACCOUNT_INFO:1549 if message.type == protocol_pb2.Message.ACCOUNT_INFO:
1557 self.purchased_bytes = message.account_info.purchased_bytes1550 self.purchased_bytes = message.account_info.purchased_bytes
1558 self.done()1551 self.done()
@@ -1682,7 +1675,7 @@
16821675
1683class StorageClientFactory(ClientFactory):1676class StorageClientFactory(ClientFactory):
1684 """StorageClient factory."""1677 """StorageClient factory."""
1685 # pylint: disable=W02321678
1686 protocol = StorageClient1679 protocol = StorageClient
16871680
16881681
@@ -1735,10 +1728,9 @@
1735 if not self.valid_limit(limit):1728 if not self.valid_limit(limit):
1736 raise ValueError('Read limit must be greater than 0.')1729 raise ValueError('Read limit must be greater than 0.')
1737 self._readLimit = limit1730 self._readLimit = limit
1738 # it's a property, pylint: disable=W02121731
1739 readLimit = property(lambda self: self._readLimit, _set_read_limit)1732 readLimit = property(lambda self: self._readLimit, _set_read_limit)
1740 writeLimit = property(lambda self: self._writeLimit, _set_write_limit)1733 writeLimit = property(lambda self: self._writeLimit, _set_write_limit)
1741 # pylint: enable=W0212
17421734
1743 def callLater(self, period, func, *args, **kwargs):1735 def callLater(self, period, func, *args, **kwargs):
1744 """Wrapper around L{reactor.callLater} for test purpose."""1736 """Wrapper around L{reactor.callLater} for test purpose."""
17451737
=== modified file 'ubuntuone/storageprotocol/content_hash.py'
--- ubuntuone/storageprotocol/content_hash.py 2016-09-19 02:00:32 +0000
+++ ubuntuone/storageprotocol/content_hash.py 2018-04-08 19:37:28 +0000
@@ -1,9 +1,7 @@
1# ubuntuone.storageprotocol.content_hash - content hash handling1# -*- coding: utf-8 -*-
2#
3# Author: Lucio Torre <lucio.torre@canonical.com>
4# Natalia B. Bidart <natalia.bidart@canonical.com>
5#2#
6# Copyright 2009-2012 Canonical Ltd.3# Copyright 2009-2012 Canonical Ltd.
4# Copyright 2015-2018 Chicharreros (https://launchpad.net/~chicharreros)
7#5#
8# This program is free software: you can redistribute it and/or modify it6# This program is free software: you can redistribute it and/or modify it
9# under the terms of the GNU Affero General Public License version 3,7# under the terms of the GNU Affero General Public License version 3,
@@ -29,6 +27,7 @@
29# do not wish to do so, delete this exception statement from your27# do not wish to do so, delete this exception statement from your
30# version. If you delete this exception statement from all source28# version. If you delete this exception statement from all source
31# files in the program, then also delete it here.29# files in the program, then also delete it here.
30
32"""Hash Handling Stuffs."""31"""Hash Handling Stuffs."""
3332
34import copy33import copy
3534
=== modified file 'ubuntuone/storageprotocol/context.py'
--- ubuntuone/storageprotocol/context.py 2015-07-17 12:59:41 +0000
+++ ubuntuone/storageprotocol/context.py 2018-04-08 19:37:28 +0000
@@ -1,6 +1,7 @@
1# ubuntuone.storageprotocol.context - ssl context creation1# -*- coding: utf-8 -*-
2#2#
3# Copyright 2009-2015 Canonical Ltd.3# Copyright 2009-2015 Canonical Ltd.
4# Copyright 2015-2018 Chicharreros (https://launchpad.net/~chicharreros)
4#5#
5# This program is free software: you can redistribute it and/or modify it6# This program is free software: you can redistribute it and/or modify it
6# under the terms of the GNU Affero General Public License version 3,7# under the terms of the GNU Affero General Public License version 3,
@@ -26,9 +27,9 @@
26# do not wish to do so, delete this exception statement from your27# do not wish to do so, delete this exception statement from your
27# version. If you delete this exception statement from all source28# version. If you delete this exception statement from all source
28# files in the program, then also delete it here.29# files in the program, then also delete it here.
29"""30
30Standard Routines for working with ssl context creation31"""Standard Routines for working with ssl context creation."""
31"""32
32import os33import os
3334
34from OpenSSL import SSL35from OpenSSL import SSL
3536
=== modified file 'ubuntuone/storageprotocol/delta.py'
--- ubuntuone/storageprotocol/delta.py 2012-12-03 19:45:43 +0000
+++ ubuntuone/storageprotocol/delta.py 2018-04-08 19:37:28 +0000
@@ -1,8 +1,7 @@
1# ubuntuone.storageprotocol.delta - delta nodes wrappers1# -*- coding: utf-8 -*-
2#
3# Author: Lucio Torre <lucio.torre@canonical.com>
4#2#
5# Copyright 2009-2012 Canonical Ltd.3# Copyright 2009-2012 Canonical Ltd.
4# Copyright 2015-2018 Chicharreros (https://launchpad.net/~chicharreros)
6#5#
7# This program is free software: you can redistribute it and/or modify it6# This program is free software: you can redistribute it and/or modify it
8# under the terms of the GNU Affero General Public License version 3,7# under the terms of the GNU Affero General Public License version 3,
@@ -28,18 +27,18 @@
28# do not wish to do so, delete this exception statement from your27# do not wish to do so, delete this exception statement from your
29# version. If you delete this exception statement from all source28# version. If you delete this exception statement from all source
30# files in the program, then also delete it here.29# files in the program, then also delete it here.
31"""30
32Provides wrapper classes for delta nodes messages31"""Provides wrapper classes for delta nodes messages."""
33"""
3432
35from ubuntuone.storageprotocol import protocol_pb233from ubuntuone.storageprotocol import protocol_pb2
3634
37FILE = 035FILE = 0
38DIRECTORY = 136DIRECTORY = 1
3937
40file_type_registry = {protocol_pb2.FileInfo.FILE: FILE,38file_type_registry = {
41 protocol_pb2.FileInfo.DIRECTORY: DIRECTORY,39 protocol_pb2.FileInfo.FILE: FILE,
42 }40 protocol_pb2.FileInfo.DIRECTORY: DIRECTORY,
41}
4342
4443
45class FileInfoDelta(object):44class FileInfoDelta(object):
4645
=== modified file 'ubuntuone/storageprotocol/dircontent.proto'
--- ubuntuone/storageprotocol/dircontent.proto 2012-03-29 20:28:09 +0000
+++ ubuntuone/storageprotocol/dircontent.proto 2018-04-08 19:37:28 +0000
@@ -1,7 +1,6 @@
1/*1/*
2 ubuntuone.storageprotocol.dircontent_pb2 - dircontent protocol
3
4 Copyright 2009-2012 Canonical Ltd.2 Copyright 2009-2012 Canonical Ltd.
3 Copyright 2015-2018 Chicharreros (https://launchpad.net/~chicharreros)
54
6 This program is free software: you can redistribute it and/or modify it 5 This program is free software: you can redistribute it and/or modify it
7 under the terms of the GNU Affero General Public License version 3,6 under the terms of the GNU Affero General Public License version 3,
87
=== modified file 'ubuntuone/storageprotocol/dircontent.py'
--- ubuntuone/storageprotocol/dircontent.py 2013-05-21 17:22:58 +0000
+++ ubuntuone/storageprotocol/dircontent.py 2018-04-08 19:37:28 +0000
@@ -1,8 +1,7 @@
1# ubuntuone.storageprotocol.dircontent - directory content handling1# -*- coding: utf-8 -*-
2#
3# Author: Tim Cole <tim.cole@canonical.com>
4#2#
5# Copyright 2009-2012 Canonical Ltd.3# Copyright 2009-2012 Canonical Ltd.
4# Copyright 2015-2018 Chicharreros (https://launchpad.net/~chicharreros)
6#5#
7# This program is free software: you can redistribute it and/or modify it6# This program is free software: you can redistribute it and/or modify it
8# under the terms of the GNU Affero General Public License version 3,7# under the terms of the GNU Affero General Public License version 3,
@@ -28,10 +27,8 @@
28# do not wish to do so, delete this exception statement from your27# do not wish to do so, delete this exception statement from your
29# version. If you delete this exception statement from all source28# version. If you delete this exception statement from all source
30# files in the program, then also delete it here.29# files in the program, then also delete it here.
31"""
32Standard routines for working with directory content.
3330
34"""31"""Standard routines for working with directory content."""
3532
36import re33import re
37from ubuntuone.storageprotocol.dircontent_pb2 import DirectoryContent34from ubuntuone.storageprotocol.dircontent_pb2 import DirectoryContent
3835
=== modified file 'ubuntuone/storageprotocol/errors.py'
--- ubuntuone/storageprotocol/errors.py 2012-12-03 19:45:43 +0000
+++ ubuntuone/storageprotocol/errors.py 2018-04-08 19:37:28 +0000
@@ -1,8 +1,7 @@
1# -*- coding: utf-8 -*-1# -*- coding: utf-8 -*-
2#2#
3# Author: Natalia B. Bidart <natalia.bidart@canonical.com>
4#
5# Copyright 2010-2012 Canonical Ltd.3# Copyright 2010-2012 Canonical Ltd.
4# Copyright 2015-2018 Chicharreros (https://launchpad.net/~chicharreros)
6#5#
7# This program is free software: you can redistribute it and/or modify it6# This program is free software: you can redistribute it and/or modify it
8# under the terms of the GNU Affero General Public License version 3,7# under the terms of the GNU Affero General Public License version 3,
@@ -28,6 +27,7 @@
28# do not wish to do so, delete this exception statement from your27# do not wish to do so, delete this exception statement from your
29# version. If you delete this exception statement from all source28# version. If you delete this exception statement from all source
30# files in the program, then also delete it here.29# files in the program, then also delete it here.
30
31"""The errors abstraction."""31"""The errors abstraction."""
3232
33import uuid33import uuid
@@ -56,9 +56,8 @@
56 @param request: the request that generated this error.56 @param request: the request that generated this error.
57 @param message: the message received that generated the error.57 @param message: the message received that generated the error.
58 """58 """
59 error_name = protocol_pb2.Error.DESCRIPTOR \59 error_name = protocol_pb2.Error.DESCRIPTOR.enum_types_by_name[
60 .enum_types_by_name['ErrorType'] \60 'ErrorType'].values_by_number[message.error.type].name
61 .values_by_number[message.error.type].name
62 super(StorageRequestError, self).__init__(error_name)61 super(StorageRequestError, self).__init__(error_name)
63 #: the request that generated the error62 #: the request that generated the error
64 self.request = request63 self.request = request
6564
=== modified file 'ubuntuone/storageprotocol/protocol.proto'
--- ubuntuone/storageprotocol/protocol.proto 2016-11-07 01:11:29 +0000
+++ ubuntuone/storageprotocol/protocol.proto 2018-04-08 19:37:28 +0000
@@ -1,6 +1,6 @@
1/*1/*
2 Copyright 2009-2012 Canonical Ltd.2 Copyright 2009-2012 Canonical Ltd.
3 Copyright 2016 Chicharreros (https://launchpad.net/~chicharreros)3 Copyright 2015-2018 Chicharreros (https://launchpad.net/~chicharreros)
44
5 This program is free software: you can redistribute it and/or modify it5 This program is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Affero General Public License version 3,6 under the terms of the GNU Affero General Public License version 3,
77
=== modified file 'ubuntuone/storageprotocol/proxy_tunnel.py'
--- ubuntuone/storageprotocol/proxy_tunnel.py 2012-03-29 20:28:09 +0000
+++ ubuntuone/storageprotocol/proxy_tunnel.py 2018-04-08 19:37:28 +0000
@@ -1,8 +1,7 @@
1# ubuntuone.storageprotocol.proxy_tunnel - tunnel through proxies1# -*- coding: utf-8 -*-
2#
3# Author: Lucio Torre <lucio.torre@canonical.com>
4#2#
5# Copyright 2009-2012 Canonical Ltd.3# Copyright 2009-2012 Canonical Ltd.
4# Copyright 2015-2018 Chicharreros (https://launchpad.net/~chicharreros)
6#5#
7# This program is free software: you can redistribute it and/or modify it6# This program is free software: you can redistribute it and/or modify it
8# under the terms of the GNU Affero General Public License version 3,7# under the terms of the GNU Affero General Public License version 3,
@@ -28,7 +27,9 @@
28# do not wish to do so, delete this exception statement from your27# do not wish to do so, delete this exception statement from your
29# version. If you delete this exception statement from all source28# version. If you delete this exception statement from all source
30# files in the program, then also delete it here.29# files in the program, then also delete it here.
31"""Proxy tunelling"""30
31"""Proxy tunelling."""
32
32import base6433import base64
3334
34from twisted.internet.protocol import Protocol, ClientFactory, connectionDone35from twisted.internet.protocol import Protocol, ClientFactory, connectionDone
@@ -70,9 +71,8 @@
70 self.client_protocol = None71 self.client_protocol = None
71 self.__buffer = ""72 self.__buffer = ""
72 # send request73 # send request
73 line = "CONNECT %s:%s HTTP/1.0\r\n" % \74 line = "CONNECT %s:%s HTTP/1.0\r\n"
74 (self.factory.host, self.factory.port)75 self.transport.write(line % (self.factory.host, self.factory.port))
75 self.transport.write(line)
76 # send headers76 # send headers
77 self.sendHeader("Host", self.factory.host)77 self.sendHeader("Host", self.factory.host)
78 # do auth78 # do auth
@@ -112,7 +112,6 @@
112 """Received a line."""112 """Received a line."""
113 if line:113 if line:
114 parts = line.split(" ", 2)114 parts = line.split(" ", 2)
115 # pylint: disable=W0612
116 version, status = parts[:2]115 version, status = parts[:2]
117 if len(parts) == 3:116 if len(parts) == 3:
118 message = parts[2]117 message = parts[2]
@@ -150,8 +149,8 @@
150149
151 def clientConnectionFailed(self, connector, reason):150 def clientConnectionFailed(self, connector, reason):
152 """Proxy client connection failed."""151 """Proxy client connection failed."""
153 self.factory.clientConnectionFailed(connector,152 self.factory.clientConnectionFailed(
154 "Proxy connection error: %s" % (str(reason)))153 connector, "Proxy connection error: %s" % (str(reason)))
155154
156155
157def connectHTTPS(proxy_host, proxy_port, host, port, factory,156def connectHTTPS(proxy_host, proxy_port, host, port, factory,
158157
=== modified file 'ubuntuone/storageprotocol/public_file_info.py'
--- ubuntuone/storageprotocol/public_file_info.py 2016-11-07 01:11:29 +0000
+++ ubuntuone/storageprotocol/public_file_info.py 2018-04-08 19:37:28 +0000
@@ -1,4 +1,6 @@
1# Copyright 2016 Chicharreros (https://launchpad.net/~chicharreros)1# -*- coding: utf-8 -*-
2#
3# Copyright 2015-2018 Chicharreros (https://launchpad.net/~chicharreros)
2#4#
3# This program is free software: you can redistribute it and/or modify it5# This program is free software: you can redistribute it and/or modify it
4# under the terms of the GNU Affero General Public License version 3,6# under the terms of the GNU Affero General Public License version 3,
57
=== modified file 'ubuntuone/storageprotocol/request.py'
--- ubuntuone/storageprotocol/request.py 2016-09-19 02:00:32 +0000
+++ ubuntuone/storageprotocol/request.py 2018-04-08 19:37:28 +0000
@@ -1,9 +1,7 @@
1# ubuntuone.storageprotocol.request - base classes for1# -*- coding: utf-8 -*-
2# network client and server
3#
4# Author: Lucio Torre <lucio.torre@canonical.com>
5#2#
6# Copyright 2009-2012 Canonical Ltd.3# Copyright 2009-2012 Canonical Ltd.
4# Copyright 2015-2018 Chicharreros (https://launchpad.net/~chicharreros)
7#5#
8# This program is free software: you can redistribute it and/or modify it6# This program is free software: you can redistribute it and/or modify it
9# under the terms of the GNU Affero General Public License version 3,7# under the terms of the GNU Affero General Public License version 3,
@@ -29,22 +27,20 @@
29# do not wish to do so, delete this exception statement from your27# do not wish to do so, delete this exception statement from your
30# version. If you delete this exception statement from all source28# version. If you delete this exception statement from all source
31# files in the program, then also delete it here.29# files in the program, then also delete it here.
32"""30
33The base classes for the network client and server.31"""The base classes for the network client and server.
3432
35This classes provide the message serialization, delivery, request33This classes provide the message serialization, delivery, request
36tracking and message handling.34tracking and message handling.
35
37"""36"""
3837
39
40import struct38import struct
41import time39import time
4240
43from twisted.internet.protocol import Protocol, connectionDone41from twisted.internet.protocol import Protocol, connectionDone
44from twisted.internet.interfaces import IPushProducer42from twisted.internet.interfaces import IPushProducer
45from twisted.internet import defer43from twisted.internet import defer
46# pylint and zope dont work
47# pylint: disable=E0611,F0401
48from zope.interface import implements44from zope.interface import implements
4945
50from ubuntuone.storageprotocol import protocol_pb2, validators46from ubuntuone.storageprotocol import protocol_pb2, validators
@@ -228,7 +224,7 @@
228 target = self.requests[message.id].processMessage224 target = self.requests[message.id].processMessage
229 try:225 try:
230 result = target(message)226 result = target(message)
231 except Exception, e: # pylint: disable=W0703227 except Exception as e:
232 self.requests[message.id].error(e)228 self.requests[message.id].error(e)
233 else:229 else:
234 name = protocol_pb2.Message.DESCRIPTOR \230 name = protocol_pb2.Message.DESCRIPTOR \
@@ -450,11 +446,10 @@
450 'error_errback' func.446 'error_errback' func.
451 """447 """
452 def _f(*args, **kwargs):448 def _f(*args, **kwargs):
453 '''Function to be called from twisted when its time arrives.'''449 """Function to be called from twisted when its time arrives."""
454 if self.cancelled:450 if self.cancelled:
455 raise RequestCancelledError("The request id=%d is cancelled! "451 msg = "The request id=%d is cancelled! (before calling %r)"
456 "(before calling %r)" %452 raise RequestCancelledError(msg % (self.id, function))
457 (self.id, function))
458 return function(*args, **kwargs)453 return function(*args, **kwargs)
459 return _f454 return _f
460455
@@ -467,7 +462,6 @@
467462
468 __slots__ = ('source_message',)463 __slots__ = ('source_message',)
469464
470 # pylint: disable=W0223
471 def __init__(self, protocol, message):465 def __init__(self, protocol, message):
472 """Create a request response.466 """Create a request response.
473467
@@ -493,7 +487,6 @@
493487
494 def _start(self):488 def _start(self):
495 """start the request sending a ping message."""489 """start the request sending a ping message."""
496 # pylint: disable=W0201
497 self.rtt = 0490 self.rtt = 0
498 self._start_time = time.time()491 self._start_time = time.time()
499 message = protocol_pb2.Message()492 message = protocol_pb2.Message()
@@ -504,8 +497,6 @@
504 def processMessage(self, message):497 def processMessage(self, message):
505 """calculate rtt if message is pong, error otherwise"""498 """calculate rtt if message is pong, error otherwise"""
506 if message.type == protocol_pb2.Message.PONG:499 if message.type == protocol_pb2.Message.PONG:
507 # pylint: disable=W0201
508 # attributes are created in completion
509 self.rtt = time.time() - self._start_time500 self.rtt = time.time() - self._start_time
510 self.done()501 self.done()
511 else:502 else:
512503
=== modified file 'ubuntuone/storageprotocol/sharersp.py'
--- ubuntuone/storageprotocol/sharersp.py 2012-03-29 20:28:09 +0000
+++ ubuntuone/storageprotocol/sharersp.py 2018-04-08 19:37:28 +0000
@@ -1,10 +1,7 @@
1# ubuntuone.storageprotocol.sharersp.py -1# -*- coding: utf-8 -*-
2# provides a handy class to use Shares
3#
4# Author: Facundo Batista <facundo@canonical.com>
5# Guillermo Gonzalez <guillermo.gonzalez@canonical.com>
6#2#
7# Copyright 2009-2012 Canonical Ltd.3# Copyright 2009-2012 Canonical Ltd.
4# Copyright 2015-2018 Chicharreros (https://launchpad.net/~chicharreros)
8#5#
9# This program is free software: you can redistribute it and/or modify it6# This program is free software: you can redistribute it and/or modify it
10# under the terms of the GNU Affero General Public License version 3,7# under the terms of the GNU Affero General Public License version 3,
@@ -30,13 +27,12 @@
30# version. If you delete this exception statement from all source27# version. If you delete this exception statement from all source
31# files in the program, then also delete it here.28# files in the program, then also delete it here.
32# along with this program. If not, see <http://www.gnu.org/licenses/>.29# along with this program. If not, see <http://www.gnu.org/licenses/>.
30
33"""A handy class to use Shares."""31"""A handy class to use Shares."""
3432
35import uuid33import uuid
3634
37from ubuntuone.storageprotocol import volumes35from ubuntuone.storageprotocol import volumes
38# Disable this warning, as we define several things outside __init__ here
39# pylint: disable=W0201
4036
4137
42class ShareResponse(object):38class ShareResponse(object):
4339
=== renamed directory 'tests' => 'ubuntuone/storageprotocol/tests'
=== modified file 'ubuntuone/storageprotocol/tests/__init__.py'
--- tests/__init__.py 2012-03-29 20:28:09 +0000
+++ ubuntuone/storageprotocol/tests/__init__.py 2018-04-08 19:37:28 +0000
@@ -1,6 +1,5 @@
1# __init__.py
2#
3# Copyright 2009-2012 Canonical Ltd.1# Copyright 2009-2012 Canonical Ltd.
2# Copyright 2015-2018 Chicharreros (https://launchpad.net/~chicharreros)
4#3#
5# This program is free software: you can redistribute it and/or modify it4# This program is free software: you can redistribute it and/or modify it
6# under the terms of the GNU Affero General Public License version 3,5# under the terms of the GNU Affero General Public License version 3,
@@ -26,4 +25,5 @@
26# do not wish to do so, delete this exception statement from your25# do not wish to do so, delete this exception statement from your
27# version. If you delete this exception statement from all source26# version. If you delete this exception statement from all source
28# files in the program, then also delete it here.27# files in the program, then also delete it here.
29"""Tests for ubuntuone.storageprotocol"""28
29"""Tests for ubuntuone.storageprotocol."""
3030
=== modified file 'ubuntuone/storageprotocol/tests/test_bytesproducer.py'
--- tests/test_bytesproducer.py 2012-03-29 20:28:09 +0000
+++ ubuntuone/storageprotocol/tests/test_bytesproducer.py 2018-04-08 19:37:28 +0000
@@ -1,9 +1,7 @@
1# ubuntuone.storageprotocol.tests.test_bytesproducer -1# -*- coding: utf-8 -*-
2# BytesMessageProducer tests
3#
4# Author: Facundo Batista <facundo@canonical.com>
5#2#
6# Copyright (C) 2009-2012 Canonical Ltd.3# Copyright (C) 2009-2012 Canonical Ltd.
4# Copyright 2015-2018 Chicharreros (https://launchpad.net/~chicharreros)
7#5#
8# This program is free software: you can redistribute it and/or modify it6# This program is free software: you can redistribute it and/or modify it
9# under the terms of the GNU Affero General Public License version 3,7# under the terms of the GNU Affero General Public License version 3,
@@ -29,6 +27,7 @@
29# do not wish to do so, delete this exception statement from your27# do not wish to do so, delete this exception statement from your
30# version. If you delete this exception statement from all source28# version. If you delete this exception statement from all source
31# files in the program, then also delete it here.29# files in the program, then also delete it here.
30
32"""Tests for directory content serialization/unserialization."""31"""Tests for directory content serialization/unserialization."""
3332
34from __future__ import with_statement33from __future__ import with_statement
@@ -52,9 +51,8 @@
5251
53 def sendMessage(self, message):52 def sendMessage(self, message):
54 """Store the message in own list."""53 """Store the message in own list."""
55 name = protocol_pb2.Message.DESCRIPTOR \54 name = protocol_pb2.Message.DESCRIPTOR.enum_types_by_name[
56 .enum_types_by_name['MessageType'] \55 'MessageType'].values_by_number[message.type].name
57 .values_by_number[message.type].name
58 self.messages.append(name)56 self.messages.append(name)
5957
6058
6159
=== modified file 'ubuntuone/storageprotocol/tests/test_client.py'
--- tests/test_client.py 2016-11-07 01:11:29 +0000
+++ ubuntuone/storageprotocol/tests/test_client.py 2018-04-08 19:37:28 +0000
@@ -1,5 +1,5 @@
1# -*- coding: utf-8 -*-1# -*- coding: utf-8 -*-
22#
3# Copyright 2009-2015 Canonical Ltd.3# Copyright 2009-2015 Canonical Ltd.
4# Copyright 2016 Chicharreros (https://launchpad.net/~chicharreros)4# Copyright 2016 Chicharreros (https://launchpad.net/~chicharreros)
5#5#
@@ -61,12 +61,8 @@
61)61)
6262
63from ubuntuone.storageprotocol import volumes63from ubuntuone.storageprotocol import volumes
64from tests import test_delta_info64from ubuntuone.storageprotocol.tests import test_delta_info
6565
66# let's not get picky about aatributes outside __init__ in tests
67# pylint: disable=W0201
68# it's ok to access internals in the test suite
69# pylint: disable=W0212
7066
71PATH = u'~/Documents/pdfs/moño/'67PATH = u'~/Documents/pdfs/moño/'
72NAME = u'UDF-me'68NAME = u'UDF-me'
@@ -217,7 +213,7 @@
217 try:213 try:
218 result = self.client.get_delta(share_id=SHARE, from_generation=0)214 result = self.client.get_delta(share_id=SHARE, from_generation=0)
219 self.assertTrue(self.called, 'GetDelta.start() was called')215 self.assertTrue(self.called, 'GetDelta.start() was called')
220 self.assertTrue(isinstance(result, Deferred))216 self.assertIsInstance(result, Deferred)
221 finally:217 finally:
222 GetDelta.start = original218 GetDelta.start = original
223219
@@ -229,7 +225,7 @@
229 try:225 try:
230 result = self.client.get_delta(share_id=SHARE, from_scratch=True)226 result = self.client.get_delta(share_id=SHARE, from_scratch=True)
231 self.assertTrue(self.called, 'GetDelta.start() was called')227 self.assertTrue(self.called, 'GetDelta.start() was called')
232 self.assertTrue(isinstance(result, Deferred))228 self.assertIsInstance(result, Deferred)
233 finally:229 finally:
234 GetDelta.start = original230 GetDelta.start = original
235231
@@ -247,7 +243,7 @@
247 try:243 try:
248 result = self.client.create_udf(path=PATH, name=NAME)244 result = self.client.create_udf(path=PATH, name=NAME)
249 self.assertTrue(self.called, 'CreateUDF.start() was called')245 self.assertTrue(self.called, 'CreateUDF.start() was called')
250 self.assertTrue(isinstance(result, Deferred))246 self.assertIsInstance(result, Deferred)
251 finally:247 finally:
252 CreateUDF.start = original248 CreateUDF.start = original
253249
@@ -259,7 +255,7 @@
259 try:255 try:
260 result = self.client.list_volumes()256 result = self.client.list_volumes()
261 self.assertTrue(self.called, 'ListVolumes.start() was called')257 self.assertTrue(self.called, 'ListVolumes.start() was called')
262 self.assertTrue(isinstance(result, Deferred))258 self.assertIsInstance(result, Deferred)
263 finally:259 finally:
264 ListVolumes.start = original260 ListVolumes.start = original
265261
@@ -271,7 +267,7 @@
271 try:267 try:
272 result = self.client.delete_volume(volume_id=VOLUME)268 result = self.client.delete_volume(volume_id=VOLUME)
273 self.assertTrue(self.called, 'DeleteVolume.start() was called')269 self.assertTrue(self.called, 'DeleteVolume.start() was called')
274 self.assertTrue(isinstance(result, Deferred))270 self.assertIsInstance(result, Deferred)
275 finally:271 finally:
276 DeleteVolume.start = original272 DeleteVolume.start = original
277273
278274
=== modified file 'ubuntuone/storageprotocol/tests/test_context.py'
--- tests/test_context.py 2016-09-19 02:00:32 +0000
+++ ubuntuone/storageprotocol/tests/test_context.py 2018-04-08 19:37:28 +0000
@@ -1,6 +1,7 @@
1# tests.test_context - test ssl context creation1# -*- coding: utf-8 -*-
2#2#
3# Copyright 2012-2015 Canonical Ltd.3# Copyright 2012-2015 Canonical Ltd.
4# Copyright 2015-2018 Chicharreros (https://launchpad.net/~chicharreros)
4#5#
5# This program is free software: you can redistribute it and/or modify it6# This program is free software: you can redistribute it and/or modify it
6# under the terms of the GNU Affero General Public License version 3,7# under the terms of the GNU Affero General Public License version 3,
@@ -87,7 +88,7 @@
87 request = crypto.X509Req()88 request = crypto.X509Req()
88 request.get_subject().CN = common_name89 request.get_subject().CN = common_name
89 request.set_pubkey(key)90 request.set_pubkey(key)
90 request.sign(key, "md5")91 request.sign(key, "sha256")
91 return request92 return request
9293
93 def _build_cert(self, request, ca_cert, ca_key):94 def _build_cert(self, request, ca_cert, ca_key):
@@ -99,7 +100,7 @@
99 certificate.set_pubkey(request.get_pubkey())100 certificate.set_pubkey(request.get_pubkey())
100 certificate.gmtime_adj_notBefore(0)101 certificate.gmtime_adj_notBefore(0)
101 certificate.gmtime_adj_notAfter(3600) # valid for one hour102 certificate.gmtime_adj_notAfter(3600) # valid for one hour
102 certificate.sign(ca_key, "md5")103 certificate.sign(ca_key, "sha256")
103 return certificate104 return certificate
104105
105106
@@ -127,6 +128,15 @@
127 self.assertEqual(result, "ok")128 self.assertEqual(result, "ok")
128129
129 @defer.inlineCallbacks130 @defer.inlineCallbacks
131 def assert_cert_failed_verify(self, server_context, client_context):
132 d = self.verify_context(server_context, client_context)
133 e = yield self.assertFailure(d, SSL.Error)
134 self.assertEqual(len(e.message), 1)
135 expected = ('SSL routines', 'ssl3_get_server_certificate',
136 'certificate verify failed')
137 self.assertEqual(e.message[0], expected)
138
139 @defer.inlineCallbacks
130 def test_no_verify(self):140 def test_no_verify(self):
131 """Test the no_verify option."""141 """Test the no_verify option."""
132 certs = FakeCerts(self, "localhost")142 certs = FakeCerts(self, "localhost")
@@ -151,9 +161,7 @@
151 client_context = context.get_ssl_context(no_verify=False,161 client_context = context.get_ssl_context(no_verify=False,
152 hostname="localhost")162 hostname="localhost")
153163
154 d = self.verify_context(server_context, client_context)164 yield self.assert_cert_failed_verify(server_context, client_context)
155 e = yield self.assertFailure(d, SSL.Error)
156 self.assertEqual(e[0][0][1], "ssl3_get_server_certificate")
157165
158 @defer.inlineCallbacks166 @defer.inlineCallbacks
159 def test_fails_hostname(self):167 def test_fails_hostname(self):
@@ -164,10 +172,7 @@
164 self.patch(context, "get_certificates", lambda: [certs.ca_cert])172 self.patch(context, "get_certificates", lambda: [certs.ca_cert])
165 client_context = context.get_ssl_context(no_verify=False,173 client_context = context.get_ssl_context(no_verify=False,
166 hostname="localhost")174 hostname="localhost")
167175 yield self.assert_cert_failed_verify(server_context, client_context)
168 d = self.verify_context(server_context, client_context)
169 e = yield self.assertFailure(d, SSL.Error)
170 self.assertEqual(e[0][0][1], "ssl3_get_server_certificate")
171176
172 @defer.inlineCallbacks177 @defer.inlineCallbacks
173 def test_matches_all(self):178 def test_matches_all(self):
174179
=== modified file 'ubuntuone/storageprotocol/tests/test_delta_info.py'
--- tests/test_delta_info.py 2012-03-29 20:28:09 +0000
+++ ubuntuone/storageprotocol/tests/test_delta_info.py 2018-04-08 19:37:28 +0000
@@ -1,8 +1,7 @@
1# -*- coding: utf-8 -*-1# -*- coding: utf-8 -*-
2#2#
3# Author: Lucio Torre <lucio.torre@canonical.com>
4#
5# Copyright (C) 2009-2012 Canonical Ltd.3# Copyright (C) 2009-2012 Canonical Ltd.
4# Copyright 2015-2018 Chicharreros (https://launchpad.net/~chicharreros)
6#5#
7# This program is free software: you can redistribute it and/or modify it6# This program is free software: you can redistribute it and/or modify it
8# under the terms of the GNU Affero General Public License version 3,7# under the terms of the GNU Affero General Public License version 3,
@@ -28,6 +27,7 @@
28# do not wish to do so, delete this exception statement from your27# do not wish to do so, delete this exception statement from your
29# version. If you delete this exception statement from all source28# version. If you delete this exception statement from all source
30# files in the program, then also delete it here.29# files in the program, then also delete it here.
30
31"""Tests for generation node data type."""31"""Tests for generation node data type."""
3232
33import unittest33import unittest
3434
=== modified file 'ubuntuone/storageprotocol/tests/test_dircontent.py'
--- tests/test_dircontent.py 2012-06-26 01:50:53 +0000
+++ ubuntuone/storageprotocol/tests/test_dircontent.py 2018-04-08 19:37:28 +0000
@@ -1,9 +1,7 @@
1# ubuntuone.storageprotocol.tests.test_dircontent -1# -*- coding: utf-8 -*-
2# directory content tests
3#
4# Author: Tim Cole <tim.cole@canonical.com>
5#2#
6# Copyright (C) 2009-2012 Canonical Ltd.3# Copyright (C) 2009-2012 Canonical Ltd.
4# Copyright 2015-2018 Chicharreros (https://launchpad.net/~chicharreros)
7#5#
8# This program is free software: you can redistribute it and/or modify it6# This program is free software: you can redistribute it and/or modify it
9# under the terms of the GNU Affero General Public License version 3,7# under the terms of the GNU Affero General Public License version 3,
@@ -29,6 +27,7 @@
29# do not wish to do so, delete this exception statement from your27# do not wish to do so, delete this exception statement from your
30# version. If you delete this exception statement from all source28# version. If you delete this exception statement from all source
31# files in the program, then also delete it here.29# files in the program, then also delete it here.
30
32"""Tests for directory content serialization/unserialization."""31"""Tests for directory content serialization/unserialization."""
3332
34from __future__ import with_statement33from __future__ import with_statement
3534
=== modified file 'ubuntuone/storageprotocol/tests/test_errors.py'
--- tests/test_errors.py 2012-03-29 20:28:09 +0000
+++ ubuntuone/storageprotocol/tests/test_errors.py 2018-04-08 19:37:28 +0000
@@ -1,8 +1,7 @@
1# -*- coding: utf-8 -*-1# -*- coding: utf-8 -*-
2#2#
3# Author: Natalia B. Bidart <natalia.bidart@canonical.com>
4#
5# Copyright (C) 2010-2012 Canonical Ltd.3# Copyright (C) 2010-2012 Canonical Ltd.
4# Copyright 2015-2018 Chicharreros (https://launchpad.net/~chicharreros)
6#5#
7# This program is free software: you can redistribute it and/or modify it6# This program is free software: you can redistribute it and/or modify it
8# under the terms of the GNU Affero General Public License version 3,7# under the terms of the GNU Affero General Public License version 3,
@@ -28,6 +27,7 @@
28# do not wish to do so, delete this exception statement from your27# do not wish to do so, delete this exception statement from your
29# version. If you delete this exception statement from all source28# version. If you delete this exception statement from all source
30# files in the program, then also delete it here.29# files in the program, then also delete it here.
30
31"""Tests for errors module."""31"""Tests for errors module."""
3232
33import unittest33import unittest
@@ -46,24 +46,18 @@
46class ErrorsTestCase(unittest.TestCase):46class ErrorsTestCase(unittest.TestCase):
47 """Basic testing of errors mapping."""47 """Basic testing of errors mapping."""
4848
49 def setUp(self):
50 """Init."""
51
52 def test_exceptions_are_storage_protocol_error(self):49 def test_exceptions_are_storage_protocol_error(self):
53 """High level exceptions inherit from StorageProtocolError."""50 """High level exceptions inherit from StorageProtocolError."""
54 for e, args in HIGH_LEVEL_ERRORS.iteritems():51 for e, args in HIGH_LEVEL_ERRORS.iteritems():
55 self.assertTrue(isinstance(e(**args), errors.StorageProtocolError),52 self.assertIsInstance(e(**args), errors.StorageProtocolError)
56 "%r must inherit from StorageProtocolError" % e)
5753
58 def test_mapping(self):54 def test_mapping(self):
59 """Protocol's specific exceptions are correct."""55 """Protocol's specific exceptions are correct."""
60 for code_error, proto_error in errors._error_mapping.iteritems():56 for code_error, proto_error in errors._error_mapping.iteritems():
61 self.assertTrue(isinstance(proto_error(**REQ_ARGS),57 self.assertIsInstance(
62 errors.StorageRequestError),58 proto_error(**REQ_ARGS), errors.StorageRequestError)
63 "%r must inherit from StorageRequestError" %59 self.assertEqual(
64 proto_error)60 proto_error, errors.error_to_exception(code_error))
65 self.assertEqual(proto_error,
66 errors.error_to_exception(code_error))
6761
68 def test_quota_exceed_error(self):62 def test_quota_exceed_error(self):
69 """QuotaExceeded error must have quota info."""63 """QuotaExceeded error must have quota info."""
7064
=== modified file 'ubuntuone/storageprotocol/tests/test_hashes.py'
--- tests/test_hashes.py 2012-03-29 20:28:09 +0000
+++ ubuntuone/storageprotocol/tests/test_hashes.py 2018-04-08 19:37:28 +0000
@@ -1,8 +1,7 @@
1# -*- coding: utf-8 -*-1# -*- coding: utf-8 -*-
2#2#
3# Author: Facundo Batista <facundo@canonical.com>
4#
5# Copyright (C) 2011-2012 Canonical Ltd.3# Copyright (C) 2011-2012 Canonical Ltd.
4# Copyright 2015-2018 Chicharreros (https://launchpad.net/~chicharreros)
6#5#
7# This program is free software: you can redistribute it and/or modify it6# This program is free software: you can redistribute it and/or modify it
8# under the terms of the GNU Affero General Public License version 3,7# under the terms of the GNU Affero General Public License version 3,
@@ -28,6 +27,7 @@
28# do not wish to do so, delete this exception statement from your27# do not wish to do so, delete this exception statement from your
29# version. If you delete this exception statement from all source28# version. If you delete this exception statement from all source
30# files in the program, then also delete it here.29# files in the program, then also delete it here.
30
31"""Tests for the protocol hashing methods."""31"""Tests for the protocol hashing methods."""
3232
33import hashlib33import hashlib
@@ -42,11 +42,6 @@
42 magic_hash_factory,42 magic_hash_factory,
43)43)
4444
45# let's not get picky about aatributes outside __init__ in tests
46# pylint: disable=W0201
47# it's ok to access internals in the test suite
48# pylint: disable=W0212
49
5045
51class FactoriesTest(unittest.TestCase):46class FactoriesTest(unittest.TestCase):
52 """Test the hasher factories."""47 """Test the hasher factories."""
@@ -54,7 +49,7 @@
54 def test_content_hash_factory(self):49 def test_content_hash_factory(self):
55 """Check the factory for the normal content hash."""50 """Check the factory for the normal content hash."""
56 o = content_hash_factory()51 o = content_hash_factory()
57 self.assertTrue(isinstance(o, SHA1ContentHash))52 self.assertIsInstance(o, SHA1ContentHash)
5853
59 def test_content_hash_method(self):54 def test_content_hash_method(self):
60 """Test the method that the normal content hash uses."""55 """Test the method that the normal content hash uses."""
@@ -67,7 +62,7 @@
67 def test_magic_hash_factory(self):62 def test_magic_hash_factory(self):
68 """Check the factory for the magic content hash."""63 """Check the factory for the magic content hash."""
69 o = magic_hash_factory()64 o = magic_hash_factory()
70 self.assertTrue(isinstance(o, MagicContentHash))65 self.assertIsInstance(o, MagicContentHash)
7166
72 def test_magic_hash_method(self):67 def test_magic_hash_method(self):
73 """Test the method that the magic content hash uses."""68 """Test the method that the magic content hash uses."""
@@ -176,7 +171,3 @@
176 # the value171 # the value
177 ch = self.hasher.content_hash()172 ch = self.hasher.content_hash()
178 self.assertRaises(NotImplementedError, pickle.dumps, ch)173 self.assertRaises(NotImplementedError, pickle.dumps, ch)
179
180
181if __name__ == '__main__':
182 unittest.main()
183174
=== modified file 'ubuntuone/storageprotocol/tests/test_proxy_tunnel.py'
--- tests/test_proxy_tunnel.py 2016-09-19 02:00:32 +0000
+++ ubuntuone/storageprotocol/tests/test_proxy_tunnel.py 2018-04-08 19:37:28 +0000
@@ -1,6 +1,7 @@
1# Test for proxy tunnel1# -*- coding: utf-8 -*-
2#2#
3# Copyright 2009-2012 Canonical Ltd.3# Copyright 2009-2012 Canonical Ltd.
4# Copyright 2015-2018 Chicharreros (https://launchpad.net/~chicharreros)
4#5#
5# This program is free software: you can redistribute it and/or modify it6# This program is free software: you can redistribute it and/or modify it
6# under the terms of the GNU Affero General Public License version 3,7# under the terms of the GNU Affero General Public License version 3,
@@ -26,9 +27,9 @@
26# do not wish to do so, delete this exception statement from your27# do not wish to do so, delete this exception statement from your
27# version. If you delete this exception statement from all source28# version. If you delete this exception statement from all source
28# files in the program, then also delete it here.29# files in the program, then also delete it here.
29"""Test for proxy tunnel"""30
3031"""Test for proxy tunnel."""
31import unittest32
32import base6433import base64
3334
34from twisted.internet.protocol import Protocol, ClientFactory, connectionDone35from twisted.internet.protocol import Protocol, ClientFactory, connectionDone
@@ -171,8 +172,8 @@
171172
172 def test_connect_auth(self):173 def test_connect_auth(self):
173 """Test connecting with auth"""174 """Test connecting with auth"""
174 return test_response("HTTP/1.0 200 Connection Made\r\n\r\n",175 return test_response(
175 auth="test:test")176 "HTTP/1.0 200 Connection Made\r\n\r\n", auth="test:test")
176177
177 def test_auth_error(self):178 def test_auth_error(self):
178 """Test auth failure"""179 """Test auth failure"""
@@ -272,12 +273,3 @@
272 FakeConnectHTTPS("test", 1, TestClientFactory(),273 FakeConnectHTTPS("test", 1, TestClientFactory(),
273 response, peer_callback=peer_callback)274 response, peer_callback=peer_callback)
274 return d275 return d
275
276
277def test_suite():
278 """Test suite"""
279 return unittest.TestLoader().loadTestsFromName(__name__)
280
281
282if __name__ == "__main__":
283 unittest.main()
284276
=== modified file 'ubuntuone/storageprotocol/tests/test_public_file_info.py'
--- tests/test_public_file_info.py 2016-11-07 01:11:29 +0000
+++ ubuntuone/storageprotocol/tests/test_public_file_info.py 2018-04-08 19:37:28 +0000
@@ -1,6 +1,6 @@
1# -*- coding: utf-8 -*-1# -*- coding: utf-8 -*-
22#
3# Copyright 2016 Chicharreros (https://launchpad.net/~chicharreros)3# Copyright 2015-2018 Chicharreros (https://launchpad.net/~chicharreros)
4#4#
5# This program is free software: you can redistribute it and/or modify it5# This program is free software: you can redistribute it and/or modify it
6# under the terms of the GNU Affero General Public License version 3,6# under the terms of the GNU Affero General Public License version 3,
77
=== modified file 'ubuntuone/storageprotocol/tests/test_putcontent.py'
--- tests/test_putcontent.py 2016-10-11 19:01:04 +0000
+++ ubuntuone/storageprotocol/tests/test_putcontent.py 2018-04-08 19:37:28 +0000
@@ -1,10 +1,7 @@
1# ubuntuone.storageprotocol.tests.test_upload_offset -1# -*- coding: utf-8 -*-
2# tests for the PutContent request
3#
4# Author: John R. Lenton <john.lenton@canonical.com>
5# Guillermo Gonzalez <guillermo.gonzalez@canonical.com>
6#2#
7# Copyright (C) 2009-2012 Canonical Ltd.3# Copyright (C) 2009-2012 Canonical Ltd.
4# Copyright 2015-2018 Chicharreros (https://launchpad.net/~chicharreros)
8#5#
9# This program is free software: you can redistribute it and/or modify it6# This program is free software: you can redistribute it and/or modify it
10# under the terms of the GNU Affero General Public License version 3,7# under the terms of the GNU Affero General Public License version 3,
@@ -30,7 +27,8 @@
30# do not wish to do so, delete this exception statement from your27# do not wish to do so, delete this exception statement from your
31# version. If you delete this exception statement from all source28# version. If you delete this exception statement from all source
32# files in the program, then also delete it here.29# files in the program, then also delete it here.
33"""Tests for PutContent request"""30
31"""Tests for PutContent request."""
3432
35import unittest33import unittest
3634
3735
=== modified file 'ubuntuone/storageprotocol/tests/test_query.py'
--- tests/test_query.py 2012-03-29 20:28:09 +0000
+++ ubuntuone/storageprotocol/tests/test_query.py 2018-04-08 19:37:28 +0000
@@ -1,9 +1,7 @@
1# ubuntuone.storageprotocol.tests.test_query -1# -*- coding: utf-8 -*-
2# query tests
3#
4# Author: John R. Lenton <john.lenton@canonical.com>
5#2#
6# Copyright (C) 2009-2012 Canonical Ltd.3# Copyright (C) 2009-2012 Canonical Ltd.
4# Copyright 2015-2018 Chicharreros (https://launchpad.net/~chicharreros)
7#5#
8# This program is free software: you can redistribute it and/or modify it6# This program is free software: you can redistribute it and/or modify it
9# under the terms of the GNU Affero General Public License version 3,7# under the terms of the GNU Affero General Public License version 3,
@@ -29,11 +27,13 @@
29# do not wish to do so, delete this exception statement from your27# do not wish to do so, delete this exception statement from your
30# version. If you delete this exception statement from all source28# version. If you delete this exception statement from all source
31# files in the program, then also delete it here.29# files in the program, then also delete it here.
32"""Tests for querying lots of items"""30
3331"""Tests for querying lots of items."""
32
33import os
34import unittest34import unittest
35
35from ubuntuone.storageprotocol.client import MultiQuery36from ubuntuone.storageprotocol.client import MultiQuery
36import os
3737
3838
39class TestQuery10(unittest.TestCase):39class TestQuery10(unittest.TestCase):
@@ -63,6 +63,3 @@
63 Check with even more queries63 Check with even more queries
64 """64 """
65 N = 100065 N = 1000
66
67if __name__ == '__main__':
68 unittest.main()
6966
=== modified file 'ubuntuone/storageprotocol/tests/test_request.py'
--- tests/test_request.py 2012-03-29 20:28:09 +0000
+++ ubuntuone/storageprotocol/tests/test_request.py 2018-04-08 19:37:28 +0000
@@ -1,10 +1,7 @@
1# ubuntuone.storageprotocol.tests.test_request -1# -*- coding: utf-8 -*-
2# request class tests
3#
4# Author: Tim Cole <tim.cole@canonical.com>
5# Author: Natalia Bidart <natalia.bidart@canonical.com>
6#2#
7# Copyright (C) 2009-2012 Canonical Ltd.3# Copyright (C) 2009-2012 Canonical Ltd.
4# Copyright 2015-2018 Chicharreros (https://launchpad.net/~chicharreros)
8#5#
9# This program is free software: you can redistribute it and/or modify it6# This program is free software: you can redistribute it and/or modify it
10# under the terms of the GNU Affero General Public License version 3,7# under the terms of the GNU Affero General Public License version 3,
@@ -30,6 +27,7 @@
30# do not wish to do so, delete this exception statement from your27# do not wish to do so, delete this exception statement from your
31# version. If you delete this exception statement from all source28# version. If you delete this exception statement from all source
32# files in the program, then also delete it here.29# files in the program, then also delete it here.
30
33"""Tests for directory content serialization/unserialization."""31"""Tests for directory content serialization/unserialization."""
3432
35from __future__ import with_statement33from __future__ import with_statement
@@ -44,9 +42,6 @@
44from ubuntuone.storageprotocol.request import (42from ubuntuone.storageprotocol.request import (
45 RequestHandler, Request, RequestResponse)43 RequestHandler, Request, RequestResponse)
4644
47# let's not get picky about attributes outside __init__ in tests
48# pylint: disable=W0201
49
5045
51class MindlessRequest(Request):46class MindlessRequest(Request):
52 """A mindless Request which never actually does anything."""47 """A mindless Request which never actually does anything."""
@@ -118,7 +113,7 @@
118 message = protocol_pb2.Message()113 message = protocol_pb2.Message()
119 self.request._default_process_message(message)114 self.request._default_process_message(message)
120115
121 self.assertTrue(isinstance(self.error, errors.StorageRequestError))116 self.assertIsInstance(self.error, errors.StorageRequestError)
122 self.assertEqual(self.request, self.error.request)117 self.assertEqual(self.request, self.error.request)
123 self.assertEqual(message, self.error.error_message)118 self.assertEqual(message, self.error.error_message)
124119
@@ -145,8 +140,7 @@
145 message.error.type = code_error140 message.error.type = code_error
146 self.request._default_process_message(message)141 self.request._default_process_message(message)
147142
148 self.assertTrue(isinstance(self.error, proto_error),143 self.assertIsInstance(self.error, proto_error)
149 "must be an instance of %r" % proto_error)
150 self.assertEqual(self.request, self.error.request)144 self.assertEqual(self.request, self.error.request)
151 self.assertEqual(message, self.error.error_message)145 self.assertEqual(message, self.error.error_message)
152146
153147
=== modified file 'ubuntuone/storageprotocol/tests/test_sharersp.py'
--- tests/test_sharersp.py 2012-12-03 19:45:43 +0000
+++ ubuntuone/storageprotocol/tests/test_sharersp.py 2018-04-08 19:37:28 +0000
@@ -1,8 +1,7 @@
1# ubuntuone.storageprotocol.tests.test_sharersp1# -*- coding: utf-8 -*-
2#
3# Author: Guillermo Gonzalez <guillermo.gonzalez@canonical.com>
4#2#
5# Copyright (C) 2010-2012 Canonical Ltd.3# Copyright (C) 2010-2012 Canonical Ltd.
4# Copyright 2015-2018 Chicharreros (https://launchpad.net/~chicharreros)
6#5#
7# This program is free software: you can redistribute it and/or modify it6# This program is free software: you can redistribute it and/or modify it
8# under the terms of the GNU Affero General Public License version 3,7# under the terms of the GNU Affero General Public License version 3,
@@ -28,6 +27,7 @@
28# do not wish to do so, delete this exception statement from your27# do not wish to do so, delete this exception statement from your
29# version. If you delete this exception statement from all source28# version. If you delete this exception statement from all source
30# files in the program, then also delete it here.29# files in the program, then also delete it here.
30
31"""Tests for shares response."""31"""Tests for shares response."""
3232
33import uuid33import uuid
@@ -66,7 +66,7 @@
66 def test_to_me(self):66 def test_to_me(self):
67 """Test ShareResponse.from_params with a 'to_me' share."""67 """Test ShareResponse.from_params with a 'to_me' share."""
68 args = (uuid.uuid4(), "to_me", uuid.uuid4(), "share_name", u"username",68 args = (uuid.uuid4(), "to_me", uuid.uuid4(), "share_name", u"username",
69 u"visible_name", True, self.access_level)69 u"visible_name", True, self.access_level)
70 share = ShareResponse.from_params(*args)70 share = ShareResponse.from_params(*args)
71 self.assertShareResponse(share, args)71 self.assertShareResponse(share, args)
7272
@@ -116,7 +116,7 @@
116 def test_to_me(self):116 def test_to_me(self):
117 """Test ShareResponse.from_params with a 'to_me' share."""117 """Test ShareResponse.from_params with a 'to_me' share."""
118 args = (uuid.uuid4(), "to_me", uuid.uuid4(), "share_name", u"username",118 args = (uuid.uuid4(), "to_me", uuid.uuid4(), "share_name", u"username",
119 u"visible_name", True, self.access_level)119 u"visible_name", True, self.access_level)
120 share = ShareResponse.from_params(*args)120 share = ShareResponse.from_params(*args)
121 share.dump_to_msg(self.msg.shares)121 share.dump_to_msg(self.msg.shares)
122 self.assertEqualShare(share,122 self.assertEqualShare(share,
123123
=== modified file 'ubuntuone/storageprotocol/tests/test_throttling.py'
--- tests/test_throttling.py 2012-03-29 20:28:09 +0000
+++ ubuntuone/storageprotocol/tests/test_throttling.py 2018-04-08 19:37:28 +0000
@@ -1,9 +1,7 @@
1# ubuntuone.storageprotocol.tests.test_throttling -1# -*- coding: utf-8 -*-
2# Throttling tests
3#
4# Author: Facundo Batista <facundo@canonical.com>
5#2#
6# Copyright (C) 2009-2012 Canonical3# Copyright (C) 2009-2012 Canonical
4# Copyright 2015-2018 Chicharreros (https://launchpad.net/~chicharreros)
7#5#
8# This program is free software: you can redistribute it and/or modify it6# This program is free software: you can redistribute it and/or modify it
9# under the terms of the GNU Affero General Public License version 3,7# under the terms of the GNU Affero General Public License version 3,
@@ -29,6 +27,7 @@
29# do not wish to do so, delete this exception statement from your27# do not wish to do so, delete this exception statement from your
30# version. If you delete this exception statement from all source28# version. If you delete this exception statement from all source
31# files in the program, then also delete it here.29# files in the program, then also delete it here.
30
32"""Tests for directory content serialization/unserialization."""31"""Tests for directory content serialization/unserialization."""
3332
34from __future__ import with_statement33from __future__ import with_statement
@@ -232,8 +231,6 @@
232231
233 def test_change_to_inavlid(self):232 def test_change_to_inavlid(self):
234 """Test setting invalid limit values after initialization."""233 """Test setting invalid limit values after initialization."""
235 # yes, this is a unittest, I need to access protected members
236 # pylint: disable=W0212
237 tscf = self.create_factory(True, 2, 2)234 tscf = self.create_factory(True, 2, 2)
238 self.assertRaises(ValueError, tscf._set_read_limit, -1)235 self.assertRaises(ValueError, tscf._set_read_limit, -1)
239 self.assertRaises(ValueError, tscf._set_write_limit, -1)236 self.assertRaises(ValueError, tscf._set_write_limit, -1)
@@ -458,8 +455,8 @@
458 self.assertEquals(None, tscf.resetReadThisSecondID)455 self.assertEquals(None, tscf.resetReadThisSecondID)
459 self.assertEquals(None, tscf.resetWriteThisSecondID)456 self.assertEquals(None, tscf.resetWriteThisSecondID)
460 tscf.enable_throttling()457 tscf.enable_throttling()
461 self.assertTrue(tscf.throttling_enabled,458 self.assertTrue(
462 "Throttling should be enabled.")459 tscf.throttling_enabled, "Throttling should be enabled.")
463 self.assertNotEquals(None, tscf.resetReadThisSecondID)460 self.assertNotEquals(None, tscf.resetReadThisSecondID)
464 self.assertNotEquals(None, tscf.resetWriteThisSecondID)461 self.assertNotEquals(None, tscf.resetWriteThisSecondID)
465 tscf.registerRead(3)462 tscf.registerRead(3)
466463
=== modified file 'ubuntuone/storageprotocol/tests/test_volumes.py'
--- tests/test_volumes.py 2012-03-29 20:28:09 +0000
+++ ubuntuone/storageprotocol/tests/test_volumes.py 2018-04-08 19:37:28 +0000
@@ -1,8 +1,7 @@
1# -*- coding: utf-8 -*-1# -*- coding: utf-8 -*-
2#2#
3# Author: Natalia B. Bidart <natalia.bidart@canonical.com>
4#
5# Copyright (C) 2009-2012 Canonical Ltd.3# Copyright (C) 2009-2012 Canonical Ltd.
4# Copyright 2015-2018 Chicharreros (https://launchpad.net/~chicharreros)
6#5#
7# This program is free software: you can redistribute it and/or modify it6# This program is free software: you can redistribute it and/or modify it
8# under the terms of the GNU Affero General Public License version 3,7# under the terms of the GNU Affero General Public License version 3,
@@ -28,6 +27,7 @@
28# do not wish to do so, delete this exception statement from your27# do not wish to do so, delete this exception statement from your
29# version. If you delete this exception statement from all source28# version. If you delete this exception statement from all source
30# files in the program, then also delete it here.29# files in the program, then also delete it here.
30
31"""Tests for volume data type."""31"""Tests for volume data type."""
3232
33import unittest33import unittest
@@ -37,9 +37,6 @@
3737
38from ubuntuone.storageprotocol import protocol_pb2, volumes38from ubuntuone.storageprotocol import protocol_pb2, volumes
3939
40# let's not get picky about aatributes outside __init__ in tests
41# pylint: disable=W0201
42
43PATH = u'~/Documents/pdfs/moño/'40PATH = u'~/Documents/pdfs/moño/'
44NAME = u'What a beatiful volume'41NAME = u'What a beatiful volume'
45VOLUME = uuid.UUID('12345678-1234-1234-1234-123456789abc')42VOLUME = uuid.UUID('12345678-1234-1234-1234-123456789abc')
@@ -79,7 +76,7 @@
7976
80 def test_is_a_volume(self):77 def test_is_a_volume(self):
81 """Test class inheritance."""78 """Test class inheritance."""
82 self.assertTrue(isinstance(self.volume, volumes.Volume))79 self.assertIsInstance(self.volume, volumes.Volume)
8380
84 def test_from_params(self):81 def test_from_params(self):
85 """Test creation using from_params."""82 """Test creation using from_params."""
@@ -108,7 +105,6 @@
108class ShareTestCase(VolumeTestCase):105class ShareTestCase(VolumeTestCase):
109 """Check Share data type."""106 """Check Share data type."""
110107
111 # pylint: disable=W0212
112 to_me = volumes._direction_prot2nice[protocol_pb2.Shares.TO_ME]108 to_me = volumes._direction_prot2nice[protocol_pb2.Shares.TO_ME]
113 only_view = volumes._access_prot2nice[protocol_pb2.Shares.VIEW]109 only_view = volumes._access_prot2nice[protocol_pb2.Shares.VIEW]
114110
@@ -133,7 +129,6 @@
133 def test_from_msg(self):129 def test_from_msg(self):
134 """Test creation using from_msg."""130 """Test creation using from_msg."""
135 message = protocol_pb2.Shares()131 message = protocol_pb2.Shares()
136 # pylint: disable=W0201
137 message.share_id = str(VOLUME)132 message.share_id = str(VOLUME)
138 message.subtree = str(NODE)133 message.subtree = str(NODE)
139 message.generation = GENERATION134 message.generation = GENERATION
@@ -161,7 +156,6 @@
161 def test_from_msg(self):156 def test_from_msg(self):
162 """Test creation using from_msg."""157 """Test creation using from_msg."""
163 message = protocol_pb2.UDFs()158 message = protocol_pb2.UDFs()
164 # pylint: disable=W0201
165 message.volume = str(VOLUME)159 message.volume = str(VOLUME)
166 message.node = str(NODE)160 message.node = str(NODE)
167 message.suggested_path = PATH161 message.suggested_path = PATH
@@ -181,13 +175,8 @@
181 def test_from_msg(self):175 def test_from_msg(self):
182 """Test creation using from_msg."""176 """Test creation using from_msg."""
183 message = protocol_pb2.Root()177 message = protocol_pb2.Root()
184 # pylint: disable=W0201
185 message.node = str(NODE)178 message.node = str(NODE)
186 message.generation = GENERATION179 message.generation = GENERATION
187 message.free_bytes = FREE_BYTES180 message.free_bytes = FREE_BYTES
188 self.volume = self.volume_class.from_msg(message)181 self.volume = self.volume_class.from_msg(message)
189 self.assert_correct_attributes()182 self.assert_correct_attributes()
190
191
192if __name__ == '__main__':
193 unittest.main()
194183
=== modified file 'ubuntuone/storageprotocol/utils.py'
--- ubuntuone/storageprotocol/utils.py 2012-03-29 20:28:09 +0000
+++ ubuntuone/storageprotocol/utils.py 2018-04-08 19:37:28 +0000
@@ -1,8 +1,7 @@
1# ubuntuone.storageprotocol.utils - some storage protocol utils1# -*- coding: utf-8 -*-
2#
3# Author: Alejandro J. Cura <alecu@canonical.com>
4#2#
5# Copyright 2011-2012 Canonical Ltd.3# Copyright 2011-2012 Canonical Ltd.
4# Copyright 2015-2018 Chicharreros (https://launchpad.net/~chicharreros)
6#5#
7# This program is free software: you can redistribute it and/or modify it6# This program is free software: you can redistribute it and/or modify it
8# under the terms of the GNU Affero General Public License version 3,7# under the terms of the GNU Affero General Public License version 3,
@@ -28,6 +27,7 @@
28# do not wish to do so, delete this exception statement from your27# do not wish to do so, delete this exception statement from your
29# version. If you delete this exception statement from all source28# version. If you delete this exception statement from all source
30# files in the program, then also delete it here.29# files in the program, then also delete it here.
30
31"""Some storage protocol utils."""31"""Some storage protocol utils."""
3232
33import logging33import logging
3434
=== modified file 'ubuntuone/storageprotocol/validators.py'
--- ubuntuone/storageprotocol/validators.py 2012-04-20 22:11:06 +0000
+++ ubuntuone/storageprotocol/validators.py 2018-04-08 19:37:28 +0000
@@ -1,5 +1,7 @@
1# -*- coding: utf-8 -*-
1#2#
2# Copyright (C) 2009-2012 Canonical Ltd.3# Copyright (C) 2009-2012 Canonical Ltd.
4# Copyright 2015-2018 Chicharreros (https://launchpad.net/~chicharreros)
3#5#
4# This program is free software: you can redistribute it and/or modify it6# This program is free software: you can redistribute it and/or modify it
5# under the terms of the GNU Affero General Public License version 3,7# under the terms of the GNU Affero General Public License version 3,
@@ -25,10 +27,12 @@
25# do not wish to do so, delete this exception statement from your27# do not wish to do so, delete this exception statement from your
26# version. If you delete this exception statement from all source28# version. If you delete this exception statement from all source
27# files in the program, then also delete it here.29# files in the program, then also delete it here.
30
28"""Message validation."""31"""Message validation."""
2932
30import re33import re
31from uuid import UUID34from uuid import UUID
35
32from google.protobuf.message import Message as _PBMessage36from google.protobuf.message import Message as _PBMessage
33from google.protobuf.internal.containers import BaseContainer as _PBContainer37from google.protobuf.internal.containers import BaseContainer as _PBContainer
34try:38try:
@@ -81,8 +85,8 @@
81 """85 """
82 # circular import86 # circular import
83 from ubuntuone.storageprotocol import request87 from ubuntuone.storageprotocol import request
84 is_valid = a_hash == '' or a_hash == request.UNKNOWN_HASH or \88 is_valid = (a_hash == '' or a_hash == request.UNKNOWN_HASH or
85 is_valid_sha1(a_hash)89 is_valid_sha1(a_hash))
86 return is_valid90 return is_valid
8791
8892
@@ -90,9 +94,6 @@
90 """94 """
91 Recursively validate a message's fields95 Recursively validate a message's fields
92 """96 """
93 # we will import ourselves
94 # pylint: disable=W0406
95
96 is_invalid = []97 is_invalid = []
97 from ubuntuone.storageprotocol import validators # this is us!98 from ubuntuone.storageprotocol import validators # this is us!
98 for descriptor, submsg in message.ListFields():99 for descriptor, submsg in message.ListFields():
@@ -114,9 +115,7 @@
114 return is_invalid115 return is_invalid
115116
116117
117# these are valid, pylint: disable=C0103
118is_valid_parent_node = is_valid_node118is_valid_parent_node = is_valid_node
119is_valid_new_parent_node = is_valid_node119is_valid_new_parent_node = is_valid_node
120is_valid_subtree = is_valid_node120is_valid_subtree = is_valid_node
121is_valid_share_id = is_valid_share121is_valid_share_id = is_valid_share
122# pylint: enable=C0103
123122
=== modified file 'ubuntuone/storageprotocol/volumes.py'
--- ubuntuone/storageprotocol/volumes.py 2012-12-03 19:45:43 +0000
+++ ubuntuone/storageprotocol/volumes.py 2018-04-08 19:37:28 +0000
@@ -1,8 +1,7 @@
1# -*- coding: utf-8 -*-1# -*- coding: utf-8 -*-
2#2#
3# Author: Natalia B. Bidart <natalia.bidart@canonical.com>
4#
5# Copyright 2009-2012 Canonical Ltd.3# Copyright 2009-2012 Canonical Ltd.
4# Copyright 2015-2018 Chicharreros (https://launchpad.net/~chicharreros)
6#5#
7# This program is free software: you can redistribute it and/or modify it6# This program is free software: you can redistribute it and/or modify it
8# under the terms of the GNU Affero General Public License version 3,7# under the terms of the GNU Affero General Public License version 3,
@@ -28,13 +27,13 @@
28# do not wish to do so, delete this exception statement from your27# do not wish to do so, delete this exception statement from your
29# version. If you delete this exception statement from all source28# version. If you delete this exception statement from all source
30# files in the program, then also delete it here.29# files in the program, then also delete it here.
30
31"""The volumes abstraction."""31"""The volumes abstraction."""
3232
33import uuid33import uuid
3434
35from ubuntuone.storageprotocol import protocol_pb235from ubuntuone.storageprotocol import protocol_pb2
3636
37# these are valid, pylint: disable=C0103
38_direction_prot2nice = {37_direction_prot2nice = {
39 protocol_pb2.Shares.FROM_ME: "from_me",38 protocol_pb2.Shares.FROM_ME: "from_me",
40 protocol_pb2.Shares.TO_ME: "to_me",39 protocol_pb2.Shares.TO_ME: "to_me",
@@ -46,7 +45,6 @@
46 protocol_pb2.Shares.MODIFY: "Modify",45 protocol_pb2.Shares.MODIFY: "Modify",
47}46}
48_access_nice2prot = dict((y, x) for x, y in _access_prot2nice.items())47_access_nice2prot = dict((y, x) for x, y in _access_prot2nice.items())
49# pylint: enable=C0103
5048
5149
52class Volume(object):50class Volume(object):

Subscribers

People subscribed via source and target branches

to all changes: