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

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

Merged
merged 12 commits into from
Mar 17, 2025

Conversation

picnixz
Copy link
Member

@picnixz picnixz commented Mar 16, 2025

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

picnixz added 9 commits March 16, 2025 11:48
- 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 picnixz force-pushed the feat/test/hmac-130149 branch from 89eadce to 3ea207e Compare March 16, 2025 11:08
@picnixz

This comment was marked as outdated.

@bedevere-bot

This comment was marked as resolved.

@picnixz
Copy link
Member Author

picnixz commented Mar 16, 2025

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!

@picnixz picnixz self-assigned this Mar 16, 2025
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
@picnixz picnixz merged commit de8890f into python:main Mar 17, 2025
42 checks passed
@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 free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants