Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

handle openssl3 error in ssl tests #655

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions cheroot/_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@
try:
import ssl
IS_ABOVE_OPENSSL10 = ssl.OPENSSL_VERSION_INFO >= (1, 1)
IS_ABOVE_OPENSSL31 = ssl.OPENSSL_VERSION_INFO >= (3, 2)
del ssl
except ImportError:
IS_ABOVE_OPENSSL10 = None
IS_ABOVE_OPENSSL31 = None

Check warning on line 15 in cheroot/_compat.py

View check run for this annotation

Codecov / codecov/patch

cheroot/_compat.py#L15

Added line #L15 was not covered by tests


IS_CI = bool(os.getenv('CI'))
Expand Down
1 change: 1 addition & 0 deletions cheroot/_compat.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ from typing import Any, ContextManager, Optional, Type, Union
def suppress(*exceptions: Type[BaseException]) -> ContextManager[None]: ...

IS_ABOVE_OPENSSL10: Optional[bool]
IS_ABOVE_OPENSSL31: Optional[bool]
IS_CI: bool
IS_GITHUB_ACTIONS_WORKFLOW: bool
IS_PYPY: bool
Expand Down
5 changes: 3 additions & 2 deletions cheroot/test/test_ssl.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import trustme

from .._compat import bton, ntob, ntou
from .._compat import IS_ABOVE_OPENSSL10, IS_CI, IS_PYPY
from .._compat import IS_ABOVE_OPENSSL10, IS_ABOVE_OPENSSL31, IS_CI, IS_PYPY
from .._compat import IS_LINUX, IS_MACOS, IS_WINDOWS
from ..server import HTTPServer, get_ssl_adapter_class
from ..testing import (
Expand Down Expand Up @@ -597,7 +597,8 @@ def test_https_over_http_error(http_server, ip_addr):
),
).request('GET', '/')
expected_substring = (
'wrong version number' if IS_ABOVE_OPENSSL10
'record layer failure' if IS_ABOVE_OPENSSL31
else 'wrong version number' if IS_ABOVE_OPENSSL10
else 'unknown protocol'
)
assert expected_substring in ssl_err.value.args[-1]
Expand Down
Loading