summaryrefslogtreecommitdiff
path: root/tests/test_smime.py
diff options
context:
space:
mode:
authorHeikki Toivonen <heikki@heikkitoivonen.net>2009-02-06 06:10:48 +0000
committerHeikki Toivonen <heikki@heikkitoivonen.net>2009-02-06 06:10:48 +0000
commitc52bd0f5f17bda31273757cb82c3ad664d6330c4 (patch)
tree97d17690c183762426325711cadc4474f12d0950 /tests/test_smime.py
parent95f69d9edc6a02f2bc1669263892065793c712e8 (diff)
downloadm2crypto-c52bd0f5f17bda31273757cb82c3ad664d6330c4.tar.gz
Bug 12713, do not raise str exceptions:
- EVP.load_key and load_key_bio fixed to raise EVP.EVPError and BIO.BIOError - SSL.Session.load_session fixed to raise SSL.SSLError - SMIME.load_pkcs7, load_pkcs7_bio, smime_load_pkcs7, smime_load_pkcs7_bio, text_crlf, text_crlf_bio fixed to raise BIO.BIOError, SMIME.PKCS7_Error and SMIME.SMIME_Error as appropriate Additionally fixed: - SMIME.text_crlf and text_crlf_bio were always raising TypeError git-svn-id: http://svn.osafoundation.org/m2crypto/trunk@663 2715db39-9adf-0310-9c64-84f055769b4b
Diffstat (limited to 'tests/test_smime.py')
-rw-r--r--tests/test_smime.py19
1 files changed, 18 insertions, 1 deletions
diff --git a/tests/test_smime.py b/tests/test_smime.py
index f79abed..a1f8b91 100644
--- a/tests/test_smime.py
+++ b/tests/test_smime.py
@@ -6,7 +6,7 @@ Copyright (C) 2006 Open Source Applications Foundation. All Rights Reserved.
"""
import unittest
-from M2Crypto import SMIME, BIO, Rand, X509
+from M2Crypto import SMIME, BIO, Rand, X509, EVP
class SMIMETestCase(unittest.TestCase):
cleartext = 'some text to manipulate'
@@ -16,6 +16,23 @@ class SMIMETestCase(unittest.TestCase):
self.signed = self.test_sign()
self.encrypted = self.test_encrypt()
+ def test_load_bad(self):
+ s = SMIME.SMIME()
+ self.assertRaises(EVP.EVPError, s.load_key,
+ 'tests/signer.pem',
+ 'tests/signer.pem')
+
+ self.assertRaises(BIO.BIOError, SMIME.load_pkcs7, 'nosuchfile-dfg456')
+ self.assertRaises(SMIME.PKCS7_Error, SMIME.load_pkcs7, 'tests/signer.pem')
+ self.assertRaises(SMIME.PKCS7_Error, SMIME.load_pkcs7_bio, BIO.MemoryBuffer('no pkcs7'))
+
+ self.assertRaises(SMIME.SMIME_Error, SMIME.smime_load_pkcs7, 'tests/signer.pem')
+ self.assertRaises(SMIME.SMIME_Error, SMIME.smime_load_pkcs7_bio, BIO.MemoryBuffer('no pkcs7'))
+
+ def test_crlf(self):
+ self.assertEqual(SMIME.text_crlf('foobar'), 'Content-Type: text/plain\r\n\r\nfoobar')
+ self.assertEqual(SMIME.text_crlf_bio(BIO.MemoryBuffer('foobar')).read(), 'Content-Type: text/plain\r\n\r\nfoobar')
+
def test_sign(self):
buf = BIO.MemoryBuffer(self.cleartext)
s = SMIME.SMIME()