fix verify_signed_message and tests/robots/1/signed_message #1354
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What does this PR do?
verify_signed_message
was not checking for the validity of the signature. The documentation ofpython-gnupg
is not clear about this, it says that the fields returned byverify
are set just if the signature is valid. In this casetests/robots/1/signed_message
was signed with the correct key but with the wrong digest-algo (SHA256
instead ofSHA512
) as expressed on the signature.Running
gpg --verify tests/robots/1/signed_message
after importing the key returned:and a non zero error code. Changing
Hash: SHA256
intests/robots/1/signed_message
returned no errors.verify_signed_message
called intest_verify_signed_message
inapi/tests/test_utils.py
was not catching this becauseverified.fingerprint
was set even thoughverified.valid
wasFalse
.I have recreated the signature with
SHA512
by running:Checklist before merging
pip install pre-commit
, thenpre-commit install
. Pre-commit installs git hooks that automatically check the codebase. If pre-commit fails when you commit your changes, please fix the problems it points out.