-
-
Notifications
You must be signed in to change notification settings - Fork 103
Fix test_https_over_http_error on Windows with OpenSSL 3.1+ #828
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
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -527,7 +527,9 @@ def test_tls_client_auth( # noqa: C901, WPS213 # FIXME | |
| "'Remote end closed connection without response'))", | ||
| ) | ||
|
|
||
| assert any(e in err_text for e in expected_substrings) | ||
| assert any(e in err_text for e in expected_substrings), ( | ||
| f'Unexpected error text: {err_text!r}' | ||
| ) | ||
|
|
||
|
|
||
| @pytest.mark.parametrize( # noqa: C901 # FIXME | ||
|
|
@@ -697,14 +699,26 @@ def test_https_over_http_error(http_server, ip_addr): | |
| http.client.HTTPSConnection( | ||
| f'{interface}:{port}', | ||
| ).request('GET', '/') | ||
| expected_substring = ( | ||
| '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] | ||
| underlying_error_string = str(ssl_err.value) | ||
| if IS_ABOVE_OPENSSL31 and IS_WINDOWS: | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @julianz- looks like it's not just Windows: https://github.com/cherrypy/cheroot/actions/runs/28048216203/job/83032035095?pr=828#step:15:131
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perhaps, we could just keep the first two blocks (if+elif) as one if-block w/o distinguishing by whether this is windows? Just merge them but keep the explanatory comments. WDYT?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes makes sense |
||
| # On Windows, the TCP reset (RST) is surfaced before OpenSSL processes | ||
| # the server's response, yielding 'wrong version number' rather than | ||
| # the usual 'record layer failure'. See CPython's own test_ssl.py: | ||
| # https://github.com/python/cpython/blob/\ | ||
| # 1b9fe5c7226eccc8b269a7443148033080399f43\ | ||
| # /Lib/test/test_ssl.py#L5705 | ||
| assert 'wrong version number' in underlying_error_string | ||
| elif IS_ABOVE_OPENSSL31: | ||
| # Newer Python returns 'record layer failure'; Python 3.8 on macOS | ||
| # returns 'wrong version number' despite OpenSSL >= 3.1. | ||
| assert ( | ||
| 'record layer failure' in underlying_error_string | ||
| or 'wrong version number' in underlying_error_string | ||
| ) | ||
| elif IS_ABOVE_OPENSSL10: | ||
| assert 'wrong version number' in underlying_error_string | ||
| else: # pragma: no cover | ||
| assert 'unknown protocol' in underlying_error_string | ||
|
|
||
|
|
||
| def test_http_over_https_no_data(mocker): | ||
|
|
||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since this patch doesn't fix a bug in Cheroot's runtime, it shouldn't be listed among bugfixes in the change log. Fixing a test is infra work. So it could be a contrib note. Perhaps, a packaging note when we declare that we support new things (like a new Python version, a new OS or a new dep in this case). Though, feel free to opt out of attaching a change note if it doesn't feel important to surface to the change log audience. You can add the
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good points. I changed to a contrib note. Regarding CPython, I get your idea but it sounds complicated. I was thinking before the issue was the version of OpenSSL but apparently macOS 15 CI runners use Python 3.14.6 with the same bundled OpenSSL 3.6.3 as Windows, but unlike Windows, macOS was already returning the correct
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you also symlink this note to 655 and 645, mentioning the prior art/contrib by radez?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, it's probably a good idea to normalize these into a unified check where possible. Maybe, migrating to
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I get the intent but wouldn't this make error extraction more complex?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @julianz- I was mainly thinking of trying to avoid relying on the internals instead. I'm not trilled that the tests are fragile due to the fact that OpenSSL works differently under different runtimes. Technically, this is something external to us and so it'd be a good idea to have it abstracted away, but still something will end up having to normalize the error processing. Anyway.. Let's postpone this for now. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| Fixed ``test_https_over_http_error`` failing on Windows with OpenSSL 3.1+, | ||
| where the SSL error message is ``wrong version number`` rather than | ||
| ``record layer failure`` -- by :user:`julianz-`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@julianz- why did you think this was necessary? pytest should already expose this automatically.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had a failure and for some reason could not see what the failure was but you're right - it's not needed.