[3006.x] Add coverage for salt/crypt.py#65417
Open
MKLeb wants to merge 1 commit intosaltstack:3006.xfrom
Open
Conversation
salt/crypt.py
s0undt3ch
suggested changes
Nov 9, 2023
Comment on lines
+27
to
+29
| key_path = str(tmp_path / "key") | ||
| with salt.utils.files.fopen(key_path, "w") as fp: | ||
| fp.write("") |
Contributor
There was a problem hiding this comment.
Suggested change
| key_path = str(tmp_path / "key") | |
| with salt.utils.files.fopen(key_path, "w") as fp: | |
| fp.write("") | |
| key_path = tmp_path / "key" | |
| key_path.touch() |
FYI
| \x1a(\x04&yL8\x19s\n\x11\x81\xfd?\xfb2\x80Ll\xa1\xdc\xc9\xb6P\xca\x8d\'\x11\xc1\ | ||
| \x07\xa5\xa1\x058\xc7\xce\xbeb\x92\xbf\x0bL\xec\xdf\xc3M\x83\xfb$\xec\xd5\xf9\ | ||
| """ | ||
| assert "1234" == salt.crypt.pwdata_decrypt(key_string, pwdata) |
Contributor
There was a problem hiding this comment.
Suggested change
| assert "1234" == salt.crypt.pwdata_decrypt(key_string, pwdata) | |
| assert salt.crypt.pwdata_decrypt(key_string, pwdata) == "1234" |
https://gist.github.com/s0undt3ch/92d065815f4ce526345f72d40a40074d
Comment on lines
+48
to
+49
| with pytest.raises(salt.crypt.SaltClientError, match="Nonce verification error"): | ||
| assert master_crypt.loads(ret, nonce="abcde") |
Contributor
There was a problem hiding this comment.
Suggested change
| with pytest.raises(salt.crypt.SaltClientError, match="Nonce verification error"): | |
| assert master_crypt.loads(ret, nonce="abcde") | |
| with pytest.raises(salt.crypt.SaltClientError, match="Nonce verification error"): | |
| master_crypt.loads(ret, nonce="abcde") |
| def test_sign_message(priv_key, msg, sig): | ||
| key = M2Crypto.RSA.load_key_string(salt.utils.stringutils.to_bytes(priv_key)) | ||
| with patch("salt.crypt.get_rsa_key", return_value=key): | ||
| assert sig == salt.crypt.sign_message("/keydir/keyname.pem", msg) |
Contributor
There was a problem hiding this comment.
Suggested change
| assert sig == salt.crypt.sign_message("/keydir/keyname.pem", msg) | |
| assert salt.crypt.sign_message("/keydir/keyname.pem", msg) == sig |
https://gist.github.com/s0undt3ch/92d065815f4ce526345f72d40a40074d
Comment on lines
+92
to
+94
| assert sig == crypt.sign_message( | ||
| "/keydir/keyname.pem", msg, passphrase="password" | ||
| ) |
Contributor
There was a problem hiding this comment.
Suggested change
| assert sig == crypt.sign_message( | |
| "/keydir/keyname.pem", msg, passphrase="password" | |
| ) | |
| assert crypt.sign_message( | |
| "/keydir/keyname.pem", msg, passphrase="password" | |
| ) == sig |
| ) | ||
| encrypted = salt.crypt.private_encrypt(loaded_priv_key, b"salt") | ||
| decrypted = salt.crypt.public_decrypt(loaded_pub_key, encrypted) | ||
| assert b"salt" == decrypted |
Contributor
There was a problem hiding this comment.
Suggested change
| assert b"salt" == decrypted | |
| assert b"salt" == decrypted |
Switch
Contributor
|
@MKLeb Need conflicts resolved and what about @s0undt3ch comments |
Contributor
|
@dwoz Do we care about crypt ? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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?
See title
What issues does this PR fix or reference?
Fixes: One file for #64739
Merge requirements satisfied?
[NOTICE] Bug fixes or features added to Salt require tests.
Commits signed with GPG?
Yes