diff options
author | Alex Gaynor <alex.gaynor@gmail.com> | 2016-03-09 07:07:52 -0500 |
---|---|---|
committer | Alex Gaynor <alex.gaynor@gmail.com> | 2016-03-09 07:07:52 -0500 |
commit | 9e753d4bfd187568c99dce5de6c2bc034aae717e (patch) | |
tree | 82825f95746f1ebf5e7c545ec4a6c5442d4bb588 /tests/hazmat | |
parent | 7830dd2111ac968f039660dd077e9c43a0f32c56 (diff) | |
parent | 1783335b8fb5dc7be3a1214ff4825eaec318b12a (diff) | |
download | cryptography-9e753d4bfd187568c99dce5de6c2bc034aae717e.tar.gz cryptography-9e753d4bfd187568c99dce5de6c2bc034aae717e.tar.bz2 cryptography-9e753d4bfd187568c99dce5de6c2bc034aae717e.zip |
Merge pull request #2774 from reaperhulk/improve-unknown-error
improve the messages from openssl InternalError
Diffstat (limited to 'tests/hazmat')
-rw-r--r-- | tests/hazmat/bindings/test_openssl.py | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/tests/hazmat/bindings/test_openssl.py b/tests/hazmat/bindings/test_openssl.py index 76a9218b..457799d3 100644 --- a/tests/hazmat/bindings/test_openssl.py +++ b/tests/hazmat/bindings/test_openssl.py @@ -6,7 +6,10 @@ from __future__ import absolute_import, division, print_function import pytest -from cryptography.hazmat.bindings.openssl.binding import Binding +from cryptography.exceptions import InternalError +from cryptography.hazmat.bindings.openssl.binding import ( + Binding, _OpenSSLErrorWithText, _openssl_assert +) class TestOpenSSL(object): @@ -149,3 +152,26 @@ class TestOpenSSL(object): else: with pytest.raises(AttributeError): b.lib.CMAC_Init + + def test_openssl_assert_error_on_stack(self): + b = Binding() + b.lib.ERR_put_error( + b.lib.ERR_LIB_EVP, + b.lib.EVP_F_EVP_ENCRYPTFINAL_EX, + b.lib.EVP_R_DATA_NOT_MULTIPLE_OF_BLOCK_LENGTH, + b"", + -1 + ) + with pytest.raises(InternalError) as exc_info: + _openssl_assert(b.lib, False) + + assert exc_info.value.err_code == [_OpenSSLErrorWithText( + code=101183626, + lib=b.lib.ERR_LIB_EVP, + func=b.lib.EVP_F_EVP_ENCRYPTFINAL_EX, + reason=b.lib.EVP_R_DATA_NOT_MULTIPLE_OF_BLOCK_LENGTH, + reason_text=( + b'error:0607F08A:digital envelope routines:EVP_EncryptFinal_' + b'ex:data not multiple of block length' + ) + )] |