Add a test for the error case of setattr
diff --git a/OpenSSL/test/test_crypto.py b/OpenSSL/test/test_crypto.py
index 2acf339..d451c9c 100644
--- a/OpenSSL/test/test_crypto.py
+++ b/OpenSSL/test/test_crypto.py
@@ -737,6 +737,7 @@
self.assertRaises(TypeError, setattr, name, None, "hello")
self.assertRaises(TypeError, setattr, name, 30, "hello")
+
def test_setInvalidAttribute(self):
"""
Attempting to set any attribute name on an :py:class:`X509NameType` instance for
@@ -926,6 +927,16 @@
"null.python.org\x00example.org", subject.commonName)
+ def test_setAttributeFailure(self):
+ """
+ If the value of an attribute cannot be set for some reason then
+ :py:class:`OpenSSL.crypto.Error` is raised.
+ """
+ name = self._x509name()
+ # This value is too long
+ self.assertRaises(Error, setattr, name, "O", b"x" * 512)
+
+
class _PKeyInteractionTestsMixin:
"""
@@ -2938,6 +2949,7 @@
self.assertRaises(Error, load_crl, FILETYPE_PEM, "hello, world")
+
class SignVerifyTests(TestCase):
"""
Tests for :py:obj:`OpenSSL.crypto.sign` and :py:obj:`OpenSSL.crypto.verify`.