diff options
author | Paul Kehrer <paul.l.kehrer@gmail.com> | 2016-03-07 23:06:19 -0400 |
---|---|---|
committer | Paul Kehrer <paul.l.kehrer@gmail.com> | 2016-03-07 23:06:19 -0400 |
commit | 73672c7c12d9dc17621ef7b54a0d94db59d0b453 (patch) | |
tree | 25b163e8e1694224ab8c6755814f42a3f50da2b6 | |
parent | d76bd668dc4b59c037771ed5619f939d65ca9905 (diff) | |
download | cryptography-73672c7c12d9dc17621ef7b54a0d94db59d0b453.tar.gz cryptography-73672c7c12d9dc17621ef7b54a0d94db59d0b453.tar.bz2 cryptography-73672c7c12d9dc17621ef7b54a0d94db59d0b453.zip |
review feedback + make the test actually test a thing
-rw-r--r-- | src/cryptography/hazmat/bindings/openssl/binding.py | 6 | ||||
-rw-r--r-- | tests/hazmat/bindings/test_openssl.py | 21 |
2 files changed, 18 insertions, 9 deletions
diff --git a/src/cryptography/hazmat/bindings/openssl/binding.py b/src/cryptography/hazmat/bindings/openssl/binding.py index 47e64191..5d7466f9 100644 --- a/src/cryptography/hazmat/bindings/openssl/binding.py +++ b/src/cryptography/hazmat/bindings/openssl/binding.py @@ -17,8 +17,8 @@ from cryptography.hazmat.bindings.openssl._conditional import CONDITIONAL_NAMES _OpenSSLError = collections.namedtuple("_OpenSSLError", ["code", "lib", "func", "reason"]) -_OpenSSLErrorText = collections.namedtuple( - "_OpenSSLErrorText", ["code", "lib", "func", "reason", "reason_text"] +_OpenSSLErrorWithText = collections.namedtuple( + "_OpenSSLErrorWithText", ["code", "lib", "func", "reason", "reason_text"] ) @@ -47,7 +47,7 @@ def _openssl_assert(lib, ok): lib.ERR_error_string(err.code, ffi.NULL) ) errors_with_text.append( - _OpenSSLErrorText( + _OpenSSLErrorWithText( err.code, err.lib, err.func, err.reason, err_text_reason ) ) diff --git a/tests/hazmat/bindings/test_openssl.py b/tests/hazmat/bindings/test_openssl.py index 73f61257..517f2420 100644 --- a/tests/hazmat/bindings/test_openssl.py +++ b/tests/hazmat/bindings/test_openssl.py @@ -8,7 +8,7 @@ import pytest from cryptography.exceptions import InternalError from cryptography.hazmat.bindings.openssl.binding import ( - Binding, _OpenSSLErrorText, _openssl_assert + Binding, _OpenSSLErrorWithText, _openssl_assert ) @@ -155,17 +155,26 @@ class TestOpenSSL(object): def test_openssl_assert_error_on_stack(self): b = Binding() - b.lib.ERR_put_error(4, 160, 110, b"", -1) + b.lib.ERR_put_error( + b.lib.ERR_LIB_RSA, + # the following value corresponds to + # RSA_F_RSA_PADDING_ADD_PKCS1_OAEP_MGF1 but we don't really bind + # func codes in our bindings. + 160, + b.lib.RSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE, + b"", + -1 + ) with pytest.raises(InternalError) as exc_info: _openssl_assert(b.lib, False) - exc_info.value.err_code == _OpenSSLErrorText( + assert exc_info.value.err_code == [_OpenSSLErrorWithText( code=67764334, - lib=4, + lib=b.lib.ERR_LIB_RSA, func=160, - reason=110, + reason=b.lib.RSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE, reason_text=( b'error:040A006E:rsa routines:RSA_padding_add_PKCS1_OAEP_mgf1' b':data too large for key size' ) - ) + )] |