summaryrefslogtreecommitdiff
path: root/tests/integration/mail/outgoing/test_outgoing.py
diff options
context:
space:
mode:
authorTulio Casagrande <tcasagra@thoughtworks.com>2017-04-21 17:20:03 -0300
committerRuben Pollan <meskio@sindominio.net>2017-12-03 20:43:37 +0100
commitfbdb541bfc0fcbf2d9c92c785f0d8ff1fe98f68a (patch)
tree147b54d3263b8354dfafc1c798558c71920b59aa /tests/integration/mail/outgoing/test_outgoing.py
parent85c0e9b95dfc3d7134e47aac7e7e485270b42b96 (diff)
[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.
Diffstat (limited to 'tests/integration/mail/outgoing/test_outgoing.py')
-rw-r--r--tests/integration/mail/outgoing/test_outgoing.py31
1 files changed, 8 insertions, 23 deletions
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)