pyopenssl
pyopenssl copied to clipboard
20.0.1: pytest warnings
+ /usr/bin/python3 -Bm pytest -ra
=========================================================================== test session starts ============================================================================
platform linux -- Python 3.8.9, pytest-6.2.4, py-1.10.0, pluggy-0.13.1
OpenSSL: b'OpenSSL 1.1.1k FIPS 25 Mar 2021'
cryptography: 3.3.1
rootdir: /home/tkloczko/rpmbuild/BUILD/pyopenssl-20.0.1, configfile: setup.cfg, testpaths: tests
plugins: forked-1.3.0, shutil-1.7.0, virtualenv-1.7.0, expect-1.1.0, httpbin-1.0.0, xdist-2.2.1, flake8-1.0.7, timeout-1.4.2, betamax-0.8.1, pyfakefs-4.4.0, freezegun-0.4.2, cases-3.4.6, case-1.5.3, isort-1.3.0, aspectlib-1.5.2, asyncio-0.15.1, toolbox-0.5, xprocess-0.17.1, flaky-3.7.0, aiohttp-0.3.0, checkdocs-2.7.0, mock-3.6.1, rerunfailures-9.1.1, requests-mock-1.9.3, hypothesis-6.13.7, Faker-8.4.0, cov-2.12.1
collected 525 items
tests/test_crypto.py ............................................................................................................................................... [ 27%]
................................................................................................................................................ [ 54%]
tests/test_debug.py . [ 54%]
tests/test_rand.py .... [ 55%]
tests/test_ssl.py .................................................................................................................................................. [ 83%]
.......................s..............s............................................... [ 99%]
tests/test_util.py . [100%]
============================================================================= warnings summary =============================================================================
../../../../../usr/lib/python3.8/site-packages/_pytest/config/__init__.py:1233
/usr/lib/python3.8/site-packages/_pytest/config/__init__.py:1233: PytestConfigWarning: Unknown config option: strict
self._warn_or_fail_if_strict(f"Unknown config option: {key}\n")
tests/test_crypto.py:39
/home/tkloczko/rpmbuild/BUILD/pyopenssl-20.0.1/tests/test_crypto.py:39: DeprecationWarning: PKCS#7 support in pyOpenSSL is deprecated. You should use the APIs in cryptography.
from OpenSSL.crypto import PKCS7, load_pkcs7_data
tests/test_crypto.py:40
/home/tkloczko/rpmbuild/BUILD/pyopenssl-20.0.1/tests/test_crypto.py:40: DeprecationWarning: PKCS#12 support in pyOpenSSL is deprecated. You should use the APIs in cryptography.
from OpenSSL.crypto import PKCS12, load_pkcs12
tests/test_ssl.py::TestContext::test_set_cipher_list[hello world:AES128-SHA1]
/home/tkloczko/rpmbuild/BUILD/pyopenssl-20.0.1/tests/test_ssl.py:493: DeprecationWarning: str for cipher_list is no longer accepted, use bytes
context.set_cipher_list(cipher_string)
tests/test_ssl.py::TestConnection::test_client_set_session
/home/tkloczko/rpmbuild/BUILD/pyopenssl-20.0.1/tests/test_ssl.py:2637: DeprecationWarning: str for buf is no longer accepted, use bytes
ctx.set_session_id("unity-test")
-- Docs: https://docs.pytest.org/en/stable/warnings.html
===Flaky Test Report===
test_gmtime_adj_notBefore passed 1 out of the required 1 times. Success!
test_gmtime_adj_notAfter passed 1 out of the required 1 times. Success!
test_set_cipher_list_no_cipher_match passed 1 out of the required 1 times. Success!
===End Flaky Test Report===
========================================================================= short test summary info ==========================================================================
SKIPPED [1] tests/test_ssl.py:3021: Python 2 only
SKIPPED [1] tests/test_ssl.py:3228: Python 2 only
=============================================================== 523 passed, 2 skipped, 5 warnings in 11.36s ================================================================
Python 2 .x is already EOSed.
Just tested 22.0.0 wit openssl 3.0.2 and looks like it is one unit less failing. There are as well some pytest warnings
+ PYTHONPATH=/home/tkloczko/rpmbuild/BUILDROOT/python-pyOpenSSL-22.0.0-2.fc35.x86_64/usr/lib64/python3.8/site-packages:/home/tkloczko/rpmbuild/BUILDROOT/python-pyOpenSSL-22.0.0-2.fc35.x86_64/usr/lib/python3.8/site-packages
+ /usr/bin/pytest -ra
=========================================================================== test session starts ============================================================================
platform linux -- Python 3.8.13, pytest-7.1.1, pluggy-1.0.0
OpenSSL: b'OpenSSL 3.0.2 15 Mar 2022'
cryptography: 36.0.2
rootdir: /home/tkloczko/rpmbuild/BUILD/pyopenssl-22.0.0, configfile: setup.cfg, testpaths: tests
plugins: flaky-3.7.0
collected 526 items
tests/test_crypto.py ...............................................................................................F............................................... [ 27%]
..............................................................................................................F................................. [ 54%]
tests/test_debug.py . [ 54%]
tests/test_rand.py .... [ 55%]
tests/test_ssl.py .....F....F....................................................................................................................................... [ 83%]
.............................................................F......................... [ 99%]
tests/test_util.py . [100%]
================================================================================= FAILURES =================================================================================
__________________________________________________________________ TestX509.test_nullbyte_subjectAltName ___________________________________________________________________
self = <tests.test_crypto.TestX509 object at 0x7f58f66e4790>
def test_nullbyte_subjectAltName(self):
"""
The fields of a `subjectAltName` extension on an X509 may contain NUL
bytes and this value is reflected in the string representation of the
extension object.
"""
cert = load_certificate(FILETYPE_PEM, nulbyteSubjectAltNamePEM)
ext = cert.get_extension(3)
assert ext.get_short_name() == b"subjectAltName"
> assert (
b"DNS:altnull.python.org\x00example.com, "
b"email:[email protected]\[email protected], "
b"URI:http://null.python.org\x00http://example.org, "
b"IP Address:192.0.2.1, IP Address:2001:DB8:0:0:0:0:0:1\n"
== str(ext).encode("ascii")
)
E AssertionError: assert b'DNS:altnull...0:0:0:0:0:1\n' == b'DNS:altnull...8:0:0:0:0:0:1'
E Use -v to get more diff
tests/test_crypto.py:2035: AssertionError
_____________________________________________________________ TestX509StoreContext.test_untrusted_self_signed ______________________________________________________________
self = <tests.test_crypto.TestX509StoreContext object at 0x7f58f5e4b760>
def test_untrusted_self_signed(self):
"""
`verify_certificate` raises error when a self-signed certificate is
verified without itself in the chain.
"""
store = X509Store()
store_ctx = X509StoreContext(store, self.root_cert)
with pytest.raises(X509StoreContextError) as exc:
store_ctx.verify_certificate()
> assert exc.value.args[0][2] == "self signed certificate"
E AssertionError: assert 'self-signed certificate' == 'self signed certificate'
E - self signed certificate
E ? ^
E + self-signed certificate
E ? ^
tests/test_crypto.py:4054: AssertionError
_____________________________________________________________ TestContext.test_set_cipher_list_no_cipher_match _____________________________________________________________
self = <tests.test_ssl.TestContext object at 0x7f58f5daebb0>, context = <OpenSSL.SSL.Context object at 0x7f58f5ead730>
@flaky.flaky
def test_set_cipher_list_no_cipher_match(self, context):
"""
`Context.set_cipher_list` raises `OpenSSL.SSL.Error` with a
`"no cipher match"` reason string regardless of the TLS
version.
"""
with pytest.raises(Error) as excinfo:
context.set_cipher_list(b"imaginary-cipher")
> assert excinfo.value.args == (
[
(
"SSL routines",
"SSL_CTX_set_cipher_list",
"no cipher match",
)
],
)
E AssertionError: assert ([('SSL routi...her match')],) == ([('SSL routi...her match')],)
E At index 0 diff: [('SSL routines', '', 'no cipher match')] != [('SSL routines', 'SSL_CTX_set_cipher_list', 'no cipher match')]
E Use -v to get more diff
tests/test_ssl.py:531: AssertionError
___________________________________________________________________ TestContext.test_set_session_id_fail ___________________________________________________________________
self = <tests.test_ssl.TestContext object at 0x7f58f5dab0a0>, context = <OpenSSL.SSL.Context object at 0x7f58f5ebad60>
def test_set_session_id_fail(self, context):
"""
`Context.set_session_id` errors are propagated.
"""
with pytest.raises(Error) as e:
context.set_session_id(b"abc" * 1000)
> assert [
(
"SSL routines",
"SSL_CTX_set_session_id_context",
"ssl session id context too long",
)
] == e.value.args[0]
E AssertionError: assert [('SSL routin...xt too long')] == [('SSL routin...xt too long')]
E At index 0 diff: ('SSL routines', 'SSL_CTX_set_session_id_context', 'ssl session id context too long') != ('SSL routines', '', 'ssl session id context too long')
E Use -v to get more diff
tests/test_ssl.py:578: AssertionError
____________________________________________________________________ TestMemoryBIO.test_unexpected_EOF _____________________________________________________________________
self = <tests.test_ssl.TestMemoryBIO object at 0x7f58f5c72fd0>
def test_unexpected_EOF(self):
"""
If the connection is lost before an orderly SSL shutdown occurs,
`OpenSSL.SSL.SysCallError` is raised with a message of
"Unexpected EOF".
"""
server_conn, client_conn = loopback()
client_conn.sock_shutdown(SHUT_RDWR)
with pytest.raises(SysCallError) as err:
> server_conn.recv(1024)
tests/test_ssl.py:3682:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
../../BUILDROOT/python-pyOpenSSL-22.0.0-2.fc35.x86_64/usr/lib/python3.8/site-packages/OpenSSL/SSL.py:1865: in recv
self._raise_ssl_error(self._ssl, result)
../../BUILDROOT/python-pyOpenSSL-22.0.0-2.fc35.x86_64/usr/lib/python3.8/site-packages/OpenSSL/SSL.py:1700: in _raise_ssl_error
_raise_current_error()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
exception_type = <class 'OpenSSL.SSL.Error'>
def exception_from_error_queue(exception_type):
"""
Convert an OpenSSL library failure into a Python exception.
When a call to the native OpenSSL library fails, this is usually signalled
by the return value, and an error code is stored in an error queue
associated with the current thread. The err library provides functions to
obtain these error codes and textual error messages.
"""
errors = []
while True:
error = lib.ERR_get_error()
if error == 0:
break
errors.append(
(
text(lib.ERR_lib_error_string(error)),
text(lib.ERR_func_error_string(error)),
text(lib.ERR_reason_error_string(error)),
)
)
> raise exception_type(errors)
E OpenSSL.SSL.Error: [('SSL routines', '', 'unexpected eof while reading')]
../../BUILDROOT/python-pyOpenSSL-22.0.0-2.fc35.x86_64/usr/lib/python3.8/site-packages/OpenSSL/_util.py:55: Error
============================================================================= warnings summary =============================================================================
../../../../../usr/lib/python3.8/site-packages/_pytest/config/__init__.py:1252
/usr/lib/python3.8/site-packages/_pytest/config/__init__.py:1252: PytestConfigWarning: Unknown config option: strict
self._warn_or_fail_if_strict(f"Unknown config option: {key}\n")
tests/test_crypto.py:39
/home/tkloczko/rpmbuild/BUILD/pyopenssl-22.0.0/tests/test_crypto.py:39: DeprecationWarning: PKCS#7 support in pyOpenSSL is deprecated. You should use the APIs in cryptography.
from OpenSSL.crypto import PKCS7, load_pkcs7_data
tests/test_crypto.py:40
/home/tkloczko/rpmbuild/BUILD/pyopenssl-22.0.0/tests/test_crypto.py:40: DeprecationWarning: PKCS#12 support in pyOpenSSL is deprecated. You should use the APIs in cryptography.
from OpenSSL.crypto import PKCS12, load_pkcs12
tests/test_crypto.py::TestCRL::test_export_md5_digest
/usr/lib/python3.8/site-packages/_pytest/python.py:192: PytestRemovedIn8Warning: Passing None has been deprecated.
See https://docs.pytest.org/en/latest/how-to/capture-warnings.html#additional-use-cases-of-warnings-in-tests for alternatives in common use cases.
result = testfunction(**testargs)
tests/test_ssl.py::TestContext::test_set_cipher_list[hello world:AES128-SHA1]
/home/tkloczko/rpmbuild/BUILD/pyopenssl-22.0.0/tests/test_ssl.py:509: DeprecationWarning: str for cipher_list is no longer accepted, use bytes
context.set_cipher_list(cipher_string)
tests/test_ssl.py::TestConnection::test_client_set_session
/home/tkloczko/rpmbuild/BUILD/pyopenssl-22.0.0/tests/test_ssl.py:2686: DeprecationWarning: str for buf is no longer accepted, use bytes
ctx.set_session_id("unity-test")
-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
===Flaky Test Report===
test_gmtime_adj_notBefore passed 1 out of the required 1 times. Success!
test_gmtime_adj_notAfter passed 1 out of the required 1 times. Success!
test_set_cipher_list_no_cipher_match failed (1 runs remaining out of 2).
<class 'AssertionError'>
assert ([('SSL routi...her match')],) == ([('SSL routi...her match')],)
At index 0 diff: [('SSL routines', '', 'no cipher match')] != [('SSL routines', 'SSL_CTX_set_cipher_list', 'no cipher match')]
Use -v to get more diff
[<TracebackEntry /home/tkloczko/rpmbuild/BUILD/pyopenssl-22.0.0/tests/test_ssl.py:531>]
test_set_cipher_list_no_cipher_match failed; it passed 0 out of the required 1 times.
<class 'AssertionError'>
assert ([('SSL routi...her match')],) == ([('SSL routi...her match')],)
At index 0 diff: [('SSL routines', '', 'no cipher match')] != [('SSL routines', 'SSL_CTX_set_cipher_list', 'no cipher match')]
Use -v to get more diff
[<TracebackEntry /home/tkloczko/rpmbuild/BUILD/pyopenssl-22.0.0/tests/test_ssl.py:531>]
===End Flaky Test Report===
========================================================================= short test summary info ==========================================================================
FAILED tests/test_crypto.py::TestX509::test_nullbyte_subjectAltName - AssertionError: assert b'DNS:altnull...0:0:0:0:0:1\n' == b'DNS:altnull...8:0:0:0:0:0:1'
FAILED tests/test_crypto.py::TestX509StoreContext::test_untrusted_self_signed - AssertionError: assert 'self-signed certificate' == 'self signed certificate'
FAILED tests/test_ssl.py::TestContext::test_set_cipher_list_no_cipher_match - AssertionError: assert ([('SSL routi...her match')],) == ([('SSL routi...her match')],)
FAILED tests/test_ssl.py::TestContext::test_set_session_id_fail - AssertionError: assert [('SSL routin...xt too long')] == [('SSL routin...xt too long')]
FAILED tests/test_ssl.py::TestMemoryBIO::test_unexpected_EOF - OpenSSL.SSL.Error: [('SSL routines', '', 'unexpected eof while reading')]
================================================================ 5 failed, 521 passed, 6 warnings in 14.31s ================================================================
Updated pytest warnings for 23.1.1:
+ PYTHONPATH=/home/tkloczko/rpmbuild/BUILDROOT/python-pyOpenSSL-23.1.1-2.fc35.x86_64/usr/lib64/python3.8/site-packages:/home/tkloczko/rpmbuild/BUILDROOT/python-pyOpenSSL-23.1.1-2.fc35.x86_64/usr/lib/python3.8/site-packages
+ /usr/bin/pytest -ra -m 'not network'
==================================================================================== test session starts ====================================================================================
platform linux -- Python 3.8.16, pytest-7.3.1, pluggy-1.0.0
OpenSSL: b'OpenSSL 3.0.5 5 Jul 2022'
cryptography: 40.0.2
rootdir: /home/tkloczko/rpmbuild/BUILD/pyopenssl-23.1.1
configfile: setup.cfg
testpaths: tests
plugins: flaky-3.7.0
collected 542 items
tests/test_crypto.py ................................................................................................................................................................ [ 29%]
.................................................................................................................................... [ 53%]
tests/test_debug.py . [ 54%]
tests/test_rand.py .... [ 54%]
tests/test_ssl.py ................................................................................................................................................................... [ 84%]
................................................................................. [ 99%]
tests/test_util.py . [100%]
===================================================================================== warnings summary ======================================================================================
../../../../../usr/lib/python3.8/site-packages/_pytest/config/__init__.py:1302
/usr/lib/python3.8/site-packages/_pytest/config/__init__.py:1302: PytestConfigWarning: Unknown config option: strict
self._warn_or_fail_if_strict(f"Unknown config option: {key}\n")
tests/test_crypto.py:22
/home/tkloczko/rpmbuild/BUILD/pyopenssl-23.1.1/tests/test_crypto.py:22: DeprecationWarning: PKCS#12 support in pyOpenSSL is deprecated. You should use the APIs in cryptography.
from OpenSSL.crypto import (
tests/test_crypto.py:22
/home/tkloczko/rpmbuild/BUILD/pyopenssl-23.1.1/tests/test_crypto.py:22: DeprecationWarning: PKCS#7 support in pyOpenSSL is deprecated. You should use the APIs in cryptography.
from OpenSSL.crypto import (
tests/test_crypto.py::TestCRL::test_export_md5_digest
/usr/lib/python3.8/site-packages/_pytest/python.py:199: PytestRemovedIn8Warning: Passing None has been deprecated.
See https://docs.pytest.org/en/latest/how-to/capture-warnings.html#additional-use-cases-of-warnings-in-tests for alternatives in common use cases.
result = testfunction(**testargs)
tests/test_ssl.py::TestContext::test_set_cipher_list[hello world:AES128-SHA1]
/home/tkloczko/rpmbuild/BUILD/pyopenssl-23.1.1/tests/test_ssl.py:502: DeprecationWarning: str for cipher_list is no longer accepted, use bytes
context.set_cipher_list(cipher_string)
tests/test_ssl.py::TestConnection::test_client_set_session
/home/tkloczko/rpmbuild/BUILD/pyopenssl-23.1.1/tests/test_ssl.py:2772: DeprecationWarning: str for buf is no longer accepted, use bytes
ctx.set_session_id("unity-test")
-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
===Flaky Test Report===
test_gmtime_adj_notBefore passed 1 out of the required 1 times. Success!
test_gmtime_adj_notAfter passed 1 out of the required 1 times. Success!
test_set_cipher_list_no_cipher_match passed 1 out of the required 1 times. Success!
===End Flaky Test Report===
============================================================================= 542 passed, 6 warnings in 11.28s ==============================================================================
Just tested that PR
+ PYTHONPATH=/home/tkloczko/rpmbuild/BUILDROOT/python-pyOpenSSL-23.1.1-2.fc35.x86_64/usr/lib64/python3.8/site-packages:/home/tkloczko/rpmbuild/BUILDROOT/python-pyOpenSSL-23.1.1-2.fc35.x86_64/usr/lib/python3.8/site-packages
+ /usr/bin/pytest -ra -m 'not network'
==================================================================================== test session starts ====================================================================================
platform linux -- Python 3.8.16, pytest-7.3.1, pluggy-1.0.0
OpenSSL: b'OpenSSL 3.0.9-dev 7 Feb 2023'
cryptography: 40.0.2
rootdir: /home/tkloczko/rpmbuild/BUILD/pyopenssl-23.1.1
configfile: setup.cfg
testpaths: tests
plugins: flaky-3.7.0
collected 542 items
tests/test_crypto.py ................................................................................................................................................................ [ 29%]
.................................................................................................................................... [ 53%]
tests/test_debug.py . [ 54%]
tests/test_rand.py .... [ 54%]
tests/test_ssl.py ................................................................................................................................................................... [ 84%]
................................................................................. [ 99%]
tests/test_util.py . [100%]
===================================================================================== warnings summary ======================================================================================
tests/test_ssl.py::TestContext::test_set_cipher_list[hello world:AES128-SHA1]
/home/tkloczko/rpmbuild/BUILD/pyopenssl-23.1.1/tests/test_ssl.py:502: DeprecationWarning: str for cipher_list is no longer accepted, use bytes
context.set_cipher_list(cipher_string)
-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
===Flaky Test Report===
test_gmtime_adj_notBefore passed 1 out of the required 1 times. Success!
test_gmtime_adj_notAfter passed 1 out of the required 1 times. Success!
test_set_cipher_list_no_cipher_match passed 1 out of the required 1 times. Success!
===End Flaky Test Report===
============================================================================== 542 passed, 1 warning in 11.70s ==============================================================================
That warning is intentional, as the test checks both string and bytes. We decided to leave it rather than capturing since adding branches to the test wasn’t desirable for a path we will remove eventually (along with the test)
ok thx 👍