summaryrefslogtreecommitdiff
path: root/src/leap/email/smtp/tests/test_encrypt.py
diff options
context:
space:
mode:
authordrebs <drebs@leap.se>2012-11-28 19:29:10 -0200
committerdrebs <drebs@leap.se>2012-11-28 19:29:10 -0200
commita59886ce1727162ad8992fdabcc38137760a8ab4 (patch)
tree59ef40afa08863936220a2fae220128a2ddc07b4 /src/leap/email/smtp/tests/test_encrypt.py
parent4539d448f2537a7221a4658a2d9771d2e2db4120 (diff)
creating test files (no tests yet)
Diffstat (limited to 'src/leap/email/smtp/tests/test_encrypt.py')
-rw-r--r--src/leap/email/smtp/tests/test_encrypt.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/leap/email/smtp/tests/test_encrypt.py b/src/leap/email/smtp/tests/test_encrypt.py
new file mode 100644
index 00000000..1051b587
--- /dev/null
+++ b/src/leap/email/smtp/tests/test_encrypt.py
@@ -0,0 +1,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__)
+