Skip to content

gh-130149: cleanup refactorization of test_hmac.py - #131318

Merged
picnixz merged 12 commits into
python:mainfrom
picnixz:feat/test/hmac-130149
Mar 17, 2025
Merged

gh-130149: cleanup refactorization of test_hmac.py#131318
picnixz merged 12 commits into
python:mainfrom
picnixz:feat/test/hmac-130149

Conversation

@picnixz

@picnixzpicnixz commented Mar 16, 2025

Copy link
Copy Markdown
Member

Backporting some changes from #130157 so that I don't need to put them out there.

- add `requires_builtin_hmac` to check if built-in HMAC is available
- refactor `requires_hashdigest` in prevision of a future
`requires_builtin_hashdigest` for built-in hashes only
- update comments for `CreatorMixin.hmac_new()`
- update comments for `DigestMixin.hmac_digest()`
- update comments for `TestVectorsMixin`
- update comments for `TestVectorsMixin.hmac_new_by_name()`
- update comments for `TestVectorsMixin.hmac_digest_by_name()`
* `assert_hmac_hexdigest_by_new` -> `assert_hmac_hexdigest_by_name`
* use a single function for checking the hexdigest.
@picnixz

This comment was marked as outdated.

@bedevere-bot

This comment was marked as outdated.

@picnixz
picnixzforce-pushed the feat/test/hmac-130149 branch from 89eadce to 3ea207eCompareMarch 16, 2025 11:08
@picnixz

This comment was marked as outdated.

@bedevere-bot

This comment was marked as resolved.

@picnixz

picnixz commented Mar 16, 2025

Copy link
Copy Markdown
MemberAuthor

Failed tests are:

 test.test_concurrent_futures.test_shutdown
test.test_multiprocessing_fork.test_misc
test.test_multiprocessing_fork.test_processes
test.test_multiprocessing_forkserver.test_misc
test.test_multiprocessing_forkserver.test_processes
test.test_multiprocessing_spawn.test_misc
test.test_multiprocessing_spawn.test_processes test___all__
test_compileall test_hashlib test_multiprocessing_main_handling
test_venv

Those tests are failing for the past year. It's virtually impossible to easily make them succeed because blake2s/2b are expected to be available. However, we are not using OpenSSL blake2s/2b due to their limited support. And since the build bot is configured in FIPS mode with no built-in hashes, we end up having no implementation at all for blake2b/2s, which results in import hashlib to fail!

@picnixzpicnixz self-assigned this Mar 16, 2025
Comment threadLib/test/test_hmac.py
Comment threadLib/test/support/hashlib_helper.py Outdated
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
@picnixz
picnixz merged commit de8890f into python:mainMar 17, 2025
@picnixz
picnixz deleted the feat/test/hmac-130149 branch March 17, 2025 10:10
plashchynski pushed a commit to plashchynski/cpython that referenced this pull request Mar 17, 2025
…1318)
New features:
* refactor `hashlib_helper.requires_hashdigest` in prevision of a future
`hashlib_helper.requires_builtin_hashdigest` for built-in hashes only
* add `hashlib_helper.requires_openssl_hashdigest` to request OpenSSL
hashes, assuming that `_hashlib` exists.
Refactoring:
* split hmac.copy() test by implementation
* update how algorithms are discovered for RFC test cases
* simplify how OpenSSL hash digests are requested
* refactor hexdigest tests for RFC test vectors
* typo fix: `assert_hmac_hexdigest_by_new` -> `assert_hmac_hexdigest_by_name`
Improvements:
* strengthen contract on `hmac_new_by_name` and `hmac_digest_by_name`
* rename mixin classes to better match their responsibility
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

@picnixz@bedevere-bot@gpshead@StanFromIreland