diff options
author | Jean-Paul Calderone <exarkun@twistedmatrix.com> | 2014-04-17 16:02:04 -0400 |
---|---|---|
committer | Jean-Paul Calderone <exarkun@twistedmatrix.com> | 2014-04-17 16:02:04 -0400 |
commit | b41d1f448cd44753387f3145a34cc6533e92835b (patch) | |
tree | 98dab0bdca53d632cf6d9863a78949a19d9db28c | |
parent | 594b980d93079cbc9472c147d43a94d5dfd0156d (diff) | |
download | pyopenssl-b41d1f448cd44753387f3145a34cc6533e92835b.tar.gz |
Add a test for the False case of Cryptography_HAS_EC.
-rw-r--r-- | OpenSSL/test/test_ssl.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/OpenSSL/test/test_ssl.py b/OpenSSL/test/test_ssl.py index ca896d9..b4f81b4 100644 --- a/OpenSSL/test/test_ssl.py +++ b/OpenSSL/test/test_ssl.py @@ -21,6 +21,7 @@ from OpenSSL.crypto import PKey, X509, X509Extension, X509Store from OpenSSL.crypto import dump_privatekey, load_privatekey from OpenSSL.crypto import dump_certificate, load_certificate +from OpenSSL.SSL import _lib from OpenSSL.SSL import OPENSSL_VERSION_NUMBER, SSLEAY_VERSION, SSLEAY_CFLAGS from OpenSSL.SSL import SSLEAY_PLATFORM, SSLEAY_DIR, SSLEAY_BUILT_ON from OpenSSL.SSL import SENT_SHUTDOWN, RECEIVED_SHUTDOWN @@ -1185,6 +1186,23 @@ class ContextTests(TestCase, _LoopbackMixin): context.set_tmp_ecdh_curve(curve) # Must not throw. + def test_set_tmp_ecdh_curve_not_available(self): + """ + :py:obj:`Context.set_tmp_ecdh_curve` raises :py:obj:`ECNotAvailable` if + elliptic curve support is not available from the underlying OpenSSL + version at all. + """ + self.addCleanup( + setattr, + _lib, "Cryptography_HAS_EC", _lib.Cryptography_HAS_EC) + _lib.Cryptography_HAS_EC = False + + context = Context(TLSv1_METHOD) + self.assertRaises( + ECNotAvailable, + context.set_tmp_ecdh_curve, next(iter(ELLIPTIC_CURVE_DESCRIPTIONS))) + + def test_set_tmp_ecdh_curve_bad_sn(self): """ :py:obj:`Context.set_tmp_ecdh_curve` raises |