From fbdb541bfc0fcbf2d9c92c785f0d8ff1fe98f68a Mon Sep 17 00:00:00 2001 From: Tulio Casagrande Date: Fri, 21 Apr 2017 17:20:03 -0300 Subject: [feat] send public key as attachment on every email Previously, we were sending the key attached as long as the contact hasn't replied back. But with new key replace scenarios, we need to updated the contact keyring with the new key. We can implement autocrypt or similar in the future, but for now, let's send the key attached on every email. --- tests/integration/mail/outgoing/test_outgoing.py | 31 ++++++------------------ 1 file changed, 8 insertions(+), 23 deletions(-) (limited to 'tests') diff --git a/tests/integration/mail/outgoing/test_outgoing.py b/tests/integration/mail/outgoing/test_outgoing.py index 1a4a7cc0..72731925 100644 --- a/tests/integration/mail/outgoing/test_outgoing.py +++ b/tests/integration/mail/outgoing/test_outgoing.py @@ -96,15 +96,12 @@ class TestOutgoingMail(KeyManagerWithSoledadTestCase): """ def check_decryption(res): decrypted, _ = res - self.assertEqual( - '\n' + self.expected_body, + self.assertIn( + self.expected_body, decrypted, - 'Decrypted text differs from plaintext.') + 'Decrypted text does not contain the original text.') - d = self._set_sign_used(ADDRESS) - d.addCallback( - lambda _: - self.outgoing_mail._maybe_encrypt_and_sign(self.raw, self.dest)) + d = self.outgoing_mail._maybe_encrypt_and_sign(self.raw, self.dest) d.addCallback(self._assert_encrypted) d.addCallback(lambda message: self.km.decrypt( message.get_payload(1).get_payload(), ADDRESS)) @@ -118,17 +115,14 @@ class TestOutgoingMail(KeyManagerWithSoledadTestCase): '""" def check_decryption_and_verify(res): decrypted, signkey = res - self.assertEqual( - '\n' + self.expected_body, + self.assertIn( + self.expected_body, decrypted, - 'Decrypted text differs from plaintext.') + 'Decrypted text does not contain the original text.') self.assertTrue(ADDRESS_2 in signkey.address, "Verification failed") - d = self._set_sign_used(ADDRESS) - d.addCallback( - lambda _: - self.outgoing_mail._maybe_encrypt_and_sign(self.raw, self.dest)) + d = self.outgoing_mail._maybe_encrypt_and_sign(self.raw, self.dest) d.addCallback(self._assert_encrypted) d.addCallback(lambda message: self.km.decrypt( message.get_payload(1).get_payload(), ADDRESS, verify=ADDRESS_2)) @@ -242,15 +236,6 @@ class TestOutgoingMail(KeyManagerWithSoledadTestCase): return self.fail("No public key attachment found") - def _set_sign_used(self, address): - def set_sign(key): - key.sign_used = True - return self.km.put_key(key) - - d = self.km.get_key(address, fetch_remote=False) - d.addCallback(set_sign) - return d - def _assert_encrypted(self, res): message, _ = res self.assertTrue('Content-Type' in message) -- cgit v1.2.3