diff options
Diffstat (limited to 'tests/integration')
-rw-r--r-- | tests/integration/mail/outgoing/test_outgoing.py | 21 | ||||
-rw-r--r-- | tests/integration/mail/smtp/test_gateway.py | 9 |
2 files changed, 16 insertions, 14 deletions
diff --git a/tests/integration/mail/outgoing/test_outgoing.py b/tests/integration/mail/outgoing/test_outgoing.py index 72731925..e2787a8b 100644 --- a/tests/integration/mail/outgoing/test_outgoing.py +++ b/tests/integration/mail/outgoing/test_outgoing.py @@ -32,6 +32,7 @@ from mock import Mock from leap.bitmask.mail.rfc3156 import RFC3156CompliantGenerator from leap.bitmask.mail.outgoing.service import OutgoingMail +from leap.bitmask.mail.outgoing.sender import SMTPSender from leap.bitmask.mail.testing import ADDRESS, ADDRESS_2, PUBLIC_KEY_2 from leap.bitmask.mail.testing import KeyManagerWithSoledadTestCase from leap.bitmask.mail.testing.smtp import getSMTPFactory @@ -75,9 +76,9 @@ class TestOutgoingMail(KeyManagerWithSoledadTestCase): self.opts = opts def init_outgoing_and_proto(_): - self.outgoing_mail = OutgoingMail( - self.fromAddr, self.km, opts.cert, - opts.key, opts.hostname, opts.port) + self.outgoing = OutgoingMail(self.fromAddr, self.km) + self.outgoing.add_sender( + SMTPSender(self.fromAddr, opts.key, opts.hostname, opts.port)) user = TEST_USER @@ -101,7 +102,7 @@ class TestOutgoingMail(KeyManagerWithSoledadTestCase): decrypted, 'Decrypted text does not contain the original text.') - d = self.outgoing_mail._maybe_encrypt_and_sign(self.raw, self.dest) + d = self.outgoing._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)) @@ -122,7 +123,7 @@ class TestOutgoingMail(KeyManagerWithSoledadTestCase): self.assertTrue(ADDRESS_2 in signkey.address, "Verification failed") - d = self.outgoing_mail._maybe_encrypt_and_sign(self.raw, self.dest) + d = self.outgoing._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)) @@ -139,9 +140,7 @@ class TestOutgoingMail(KeyManagerWithSoledadTestCase): return_value=fail(errors.KeyNotFound())) recipient = User('ihavenopubkey@nonleap.se', 'gateway.leap.se', self.proto, ADDRESS) - self.outgoing_mail = OutgoingMail( - self.fromAddr, self.km, self.opts.cert, self.opts.key, - self.opts.hostname, self.opts.port) + self.outgoing = OutgoingMail(self.fromAddr, self.km) def check_signed(res): message, _ = res @@ -187,13 +186,13 @@ class TestOutgoingMail(KeyManagerWithSoledadTestCase): return d # TODO shouldn't depend on private method on this test - d = self.outgoing_mail._maybe_encrypt_and_sign(self.raw, recipient) + d = self.outgoing._maybe_encrypt_and_sign(self.raw, recipient) d.addCallback(check_signed) d.addCallback(verify) return d def test_attach_key(self): - d = self.outgoing_mail._maybe_encrypt_and_sign(self.raw, self.dest) + d = self.outgoing._maybe_encrypt_and_sign(self.raw, self.dest) d.addCallback(self._assert_encrypted) d.addCallback(self._check_headers, self.lines[:4]) d.addCallback(lambda message: self.km.decrypt( @@ -209,7 +208,7 @@ class TestOutgoingMail(KeyManagerWithSoledadTestCase): raw = '\r\n'.join(lines) dest = User(unknown_address, 'gateway.leap.se', self.proto, ADDRESS_2) - d = self.outgoing_mail._maybe_encrypt_and_sign( + d = self.outgoing._maybe_encrypt_and_sign( raw, dest, fetch_remote=False) d.addCallback(lambda (message, _): self._check_headers(message, lines[:4])) diff --git a/tests/integration/mail/smtp/test_gateway.py b/tests/integration/mail/smtp/test_gateway.py index aac90b50..254ee029 100644 --- a/tests/integration/mail/smtp/test_gateway.py +++ b/tests/integration/mail/smtp/test_gateway.py @@ -29,6 +29,7 @@ from twisted.test import proto_helpers from mock import Mock from leap.bitmask.keymanager import openpgp, errors +from leap.bitmask.mail.outgoing.service import OutgoingMail from leap.bitmask.mail.testing import KeyManagerWithSoledadTestCase from leap.bitmask.mail.testing import ADDRESS, ADDRESS_2 from leap.bitmask.mail.testing.smtp import getSMTPFactory, TEST_USER @@ -91,7 +92,8 @@ class TestSmtpGateway(KeyManagerWithSoledadTestCase): '354 Continue'] user = TEST_USER - proto = getSMTPFactory({user: None}, {user: self.km}, {user: None}) + proto = getSMTPFactory({user: OutgoingMail(user, self.km)}, + {user: None}) transport = proto_helpers.StringTransport() proto.makeConnection(transport) reply = "" @@ -117,7 +119,7 @@ class TestSmtpGateway(KeyManagerWithSoledadTestCase): return_value=fail(errors.KeyNotFound())) user = TEST_USER proto = getSMTPFactory( - {user: None}, {user: self.km}, {user: None}, + {user: OutgoingMail(user, self.km)}, {user: None}, encrypted_only=True) transport = proto_helpers.StringTransport() proto.makeConnection(transport) @@ -147,7 +149,8 @@ class TestSmtpGateway(KeyManagerWithSoledadTestCase): self.km._fetch_keys_from_server_and_store_local = Mock( return_value=fail(errors.KeyNotFound())) user = TEST_USER - proto = getSMTPFactory({user: None}, {user: self.km}, {user: None}) + proto = getSMTPFactory({user: OutgoingMail(user, self.km)}, + {user: None}) transport = proto_helpers.StringTransport() proto.makeConnection(transport) yield self.getReply(self.EMAIL_DATA[0] + '\r\n', proto, transport) |