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

Adding get_pem_for_key and normalize_pem methods to normalize PEM formatting of keys #356

Merged
merged 1 commit into from
May 30, 2024

Conversation

twwildey
Copy link
Collaborator

Adding get_pem_for_key and normalize_pem methods to normalize PEM formatting of keys in tests/algorithms/test_EC.py and updating tests/algorithms/test_EC_compat.py to use these methods

Test failures were occurring due to differences of line lengths generated by the cryptography vs ecdsa PIP libraries for PEM formatting of cryptographic keys. This method removes newlines from the bodies of PEM-formated keys so that test comparisons will not fail on differentiated line lengths between PEM formattings.

Testing done

Ran the following:

python -m tox

Which succeeded:

pypy3-base: skipped because could not find python interpreter with spec(s): pypy3
pypy3-base: SKIP ⚠ in 0.03 seconds
pypy3-cryptography-only: skipped because could not find python interpreter with spec(s): pypy3
pypy3-cryptography-only: SKIP ⚠ in 0.01 seconds
pypy3-pycryptodome-norsa: skipped because could not find python interpreter with spec(s): pypy3
pypy3-pycryptodome-norsa: SKIP ⚠ in 0.02 seconds
pypy3-compatibility: skipped because could not find python interpreter with spec(s): pypy3
pypy3-compatibility: SKIP ⚠ in 0.02 seconds
lint: commands[0]> flake8 jose setup.py
lint: commands[1]> isort jose tests setup.py --check-only
lint: commands[2]> black . --check
All done! ✨ 🍰 ✨
38 files would be left unchanged.
  py37-base: SKIP (0.04 seconds)
  py37-cryptography-only: SKIP (0.01 seconds)
  py37-pycryptodome-norsa: SKIP (0.01 seconds)
  py37-compatibility: SKIP (0.01 seconds)
  py38-base: OK (11.13=setup[7.59]+cmd[0.39,3.16] seconds)
  py38-cryptography-only: OK (13.92=setup[5.05]+cmd[1.02,0.42,7.42] seconds)
  py38-pycryptodome-norsa: OK (7.88=setup[4.82]+cmd[1.03,0.44,1.59] seconds)
  py38-compatibility: OK (26.50=setup[4.88]+cmd[0.38,21.24] seconds)
  py39-base: OK (8.07=setup[4.89]+cmd[0.36,2.82] seconds)
  py39-cryptography-only: OK (13.51=setup[4.92]+cmd[0.99,0.40,7.20] seconds)
  py39-pycryptodome-norsa: OK (7.56=setup[4.71]+cmd[0.98,0.40,1.47] seconds)
  py39-compatibility: OK (26.49=setup[4.89]+cmd[0.44,21.16] seconds)
  py310-base: OK (7.71=setup[4.63]+cmd[0.35,2.73] seconds)
  py310-cryptography-only: OK (14.19=setup[4.53]+cmd[0.98,0.39,8.29] seconds)
  py310-pycryptodome-norsa: OK (7.63=setup[4.79]+cmd[1.01,0.42,1.42] seconds)
  py310-compatibility: OK (25.88=setup[4.60]+cmd[0.34,20.93] seconds)
  py311-base: OK (7.77=setup[4.71]+cmd[0.34,2.72] seconds)
  py311-cryptography-only: OK (13.23=setup[4.52]+cmd[1.00,0.38,7.33] seconds)
  py311-pycryptodome-norsa: OK (7.33=setup[4.55]+cmd[0.99,0.38,1.40] seconds)
  py311-compatibility: OK (26.22=setup[4.60]+cmd[0.34,21.28] seconds)
  pypy3-base: SKIP (0.03 seconds)
  pypy3-cryptography-only: SKIP (0.01 seconds)
  pypy3-pycryptodome-norsa: SKIP (0.01 seconds)
  pypy3-compatibility: SKIP (0.02 seconds)
  lint: OK (1.70=setup[0.02]+cmd[0.92,0.38,0.38] seconds)
  congratulations :) (227.00 seconds)

… formatting of keys in `tests/algorithms/test_EC.py` and updating `tests/algorithms/test_EC_compat.py` to use these methods

Test failures were occurring due to differences of line lengths generated by the `cryptography` vs `ecdsa` PIP libraries for PEM formatting of cryptographic keys.  This method removes newlines from the bodies of PEM-formated keys so that test comparisons will not fail on differentiated line lengths between PEM formattings.
@twwildey twwildey merged commit 1967754 into mpdavis:master May 30, 2024
17 of 18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant