From aef72180f681a46534c0d934a62c1376ea2489db Mon Sep 17 00:00:00 2001 From: Victor Shyba Date: Wed, 20 Sep 2017 03:54:51 -0300 Subject: [feature] improve preamble comparisons We were comparing the raw content of preambles. This commit adds a way to compare excluding time so comparisons don't suffer from false negatives caused by time deltas. -- Resolves: #8920 --- tests/server/test_incoming_server.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/server/test_incoming_server.py b/tests/server/test_incoming_server.py index 241bc581..8c22b13b 100644 --- a/tests/server/test_incoming_server.py +++ b/tests/server/test_incoming_server.py @@ -31,6 +31,7 @@ from leap.soledad.server._incoming import IncomingResource from leap.soledad.server._blobs import BlobsServerState from leap.soledad.server._incoming import IncomingFormatter from leap.soledad.common.crypto import EncryptionSchemes +from leap.soledad.common.blobs.preamble import decode_preamble from leap.soledad.common.blobs import Flags from test_soledad.util import CouchServerStateForTests from test_soledad.util import CouchDBTestCase @@ -87,6 +88,10 @@ 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 - self.assertEquals(expected, request.written[0]) + expected_preamble = formatter.preamble(content, doc_id) + expected_preamble = decode_preamble(expected_preamble, True) + written_preamble, written_content = request.written[0].split() + written_preamble = decode_preamble(written_preamble, True) + self.assertEquals(expected_preamble, written_preamble) + self.assertEquals(content, written_content) self.assertIn(Flags.PENDING, flags) -- cgit v1.2.3