summaryrefslogtreecommitdiff
path: root/src/leap/email/smtp/tests/test_encrypt.py
blob: 1051b5875d3ae854c006736d7b91692afd1b1af8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import os
import unittest
import gnupg

class EncryptMessageTestCase(unittest.TestCase):

    def test_encrypt_to_signonly(self):
        plaintext = BytesIO(b'Hello World\n')
        ciphertext = BytesIO()
        ctx = gpgme.Context()
        recipient = ctx.get_key('15E7CE9BF1771A4ABC550B31F540A569CB935A42')
        try:
            ctx.encrypt([recipient], gpgme.ENCRYPT_ALWAYS_TRUST,
                        plaintext, ciphertext)
        except gpgme.GpgmeError as exc:
            self.assertEqual(exc.args[0], gpgme.ERR_SOURCE_UNKNOWN)
            self.assertEqual(exc.args[1], gpgme.ERR_GENERAL)
        else:
            self.fail('gpgme.GpgmeError not raised')


def test_suite():
    loader = unittest.TestLoader()
    return loader.loadTestsFromName(__name__)