summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVictor Shyba <victor1984@riseup.net>2017-07-25 05:51:37 -0300
committerVictor Shyba <victor1984@riseup.net>2017-08-03 05:33:01 -0300
commit7007606e2fc10a836bb52ef3eb40db8b15f3c4ac (patch)
treea98f82bb148d61d460266961d1324f96ae637cb1
parent639d86626b8e519a966578b48b77c68f7076be35 (diff)
[bug] separate preamble from content on incoming resource
-rw-r--r--src/leap/soledad/server/_incoming.py8
-rw-r--r--testing/tests/server/test_incoming_server.py2
2 files changed, 6 insertions, 4 deletions
diff --git a/src/leap/soledad/server/_incoming.py b/src/leap/soledad/server/_incoming.py
index 1d34f4f3..5dbbb627 100644
--- a/src/leap/soledad/server/_incoming.py
+++ b/src/leap/soledad/server/_incoming.py
@@ -18,6 +18,7 @@
A twisted resource that saves externally delivered documents into user's db.
"""
import json
+import base64
from twisted.web.server import NOT_DONE_YET
from twisted.web.resource import Resource
from twisted.web.test.test_web import DummyRequest
@@ -66,7 +67,7 @@ class IncomingResource(Resource):
else:
raw_content = request.content.read()
preamble = self.formatter.preamble(raw_content, doc_id)
- request.content = BytesIO(preamble + raw_content)
+ request.content = BytesIO(preamble + ' ' + raw_content)
d = db.write_blob(uuid, doc_id, request, namespace='MX')
# FIXME: We really need to decouple request handling from the
# backend! This is very ugly, but will change when this refactor
@@ -107,5 +108,6 @@ class IncomingFormatter(object):
scheme = preamble.ENC_SCHEME.external
method = preamble.ENC_METHOD.pgp
size = len(raw_content)
- return preamble.Preamble(doc_id, rev, scheme, method,
- content_size=size).encode()
+ raw_preamble = preamble.Preamble(doc_id, rev, scheme, method,
+ content_size=size).encode()
+ return base64.urlsafe_b64encode(raw_preamble)
diff --git a/testing/tests/server/test_incoming_server.py b/testing/tests/server/test_incoming_server.py
index 55eb8931..241bc581 100644
--- a/testing/tests/server/test_incoming_server.py
+++ b/testing/tests/server/test_incoming_server.py
@@ -87,6 +87,6 @@ class IncomingOnCouchServerTestCase(CouchDBTestCase):
yield db.read_blob(user_id, doc_id, request, 'MX')
flags = db.get_flags(user_id, doc_id, request, 'MX')
flags = json.loads(flags)
- expected = formatter.preamble(content, doc_id) + content
+ expected = formatter.preamble(content, doc_id) + ' ' + content
self.assertEquals(expected, request.written[0])
self.assertIn(Flags.PENDING, flags)