summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVictor Shyba <victor1984@riseup.net>2017-08-10 00:39:50 -0300
committerKali Kaneko <kali@leap.se>2017-08-11 18:52:08 -0400
commit05b5c10b6c2eeb5a05963c1489e576a5e12a89c9 (patch)
treeba9c7b816ae015f9abe0f36b38551f5c481f3d1d
parent78621bb742cd0a816dc507010743a7d765d84538 (diff)
[bug] enforce namespace to default on server
This commit is complementary to the previous one. It adds a test for the reported bug (listing default namespace was listing others) and fixes it. -- Related: #8882
-rw-r--r--src/leap/soledad/server/_blobs.py3
-rw-r--r--testing/tests/server/test_blobs_server.py12
2 files changed, 14 insertions, 1 deletions
diff --git a/src/leap/soledad/server/_blobs.py b/src/leap/soledad/server/_blobs.py
index dc2c204c..f7db9218 100644
--- a/src/leap/soledad/server/_blobs.py
+++ b/src/leap/soledad/server/_blobs.py
@@ -143,6 +143,7 @@ class FilesystemBlobsBackend(object):
def list_blobs(self, user, request, namespace='', order_by=None,
filter_flag=False):
+ namespace = namespace or 'default'
blob_ids = []
base_path = self._get_path(user, namespace=namespace)
for root, dirs, filenames in os.walk(base_path):
@@ -286,7 +287,7 @@ class BlobsResource(resource.Resource):
for arg in request.postpath:
if arg and not VALID_STRINGS.match(arg):
raise Exception('Invalid blob resource argument: %s' % arg)
- namespace = request.args.get('namespace', [''])[0]
+ namespace = request.args.get('namespace', ['default'])[0]
if namespace and not VALID_STRINGS.match(namespace):
raise Exception('Invalid blob namespace: %s' % namespace)
return request.postpath + [namespace]
diff --git a/testing/tests/server/test_blobs_server.py b/testing/tests/server/test_blobs_server.py
index f57a1d2d..36709ce6 100644
--- a/testing/tests/server/test_blobs_server.py
+++ b/testing/tests/server/test_blobs_server.py
@@ -195,6 +195,18 @@ class BlobServerTestCase(unittest.TestCase):
@defer.inlineCallbacks
@pytest.mark.usefixtures("method_tmpdir")
+ def test_list_default_doesnt_list_other_namespaces(self):
+ manager = BlobManager('', self.uri, self.secret,
+ self.secret, 'user')
+ namespace = 'incoming'
+ yield manager._encrypt_and_upload('blob_id1', BytesIO("1"),
+ namespace=namespace)
+ yield manager._encrypt_and_upload('blob_id2', BytesIO("2"))
+ blobs_list = yield manager.remote_list()
+ self.assertEquals(['blob_id2'], blobs_list)
+
+ @defer.inlineCallbacks
+ @pytest.mark.usefixtures("method_tmpdir")
def test_download_from_namespace(self):
manager = BlobManager('', self.uri, self.secret,
self.secret, 'user')