-
Notifications
You must be signed in to change notification settings - Fork 5.6k
[3006.x] Add coverage for salt/crypt.py
#65417
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
base: 3006.x
Are you sure you want to change the base?
Conversation
salt/crypt.py
| key_path = str(tmp_path / "key") | ||
| with salt.utils.files.fopen(key_path, "w") as fp: | ||
| fp.write("") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| 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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| assert "1234" == salt.crypt.pwdata_decrypt(key_string, pwdata) | |
| assert salt.crypt.pwdata_decrypt(key_string, pwdata) == "1234" |
https://gist.github.com/s0undt3ch/92d065815f4ce526345f72d40a40074d
| with pytest.raises(salt.crypt.SaltClientError, match="Nonce verification error"): | ||
| assert master_crypt.loads(ret, nonce="abcde") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| 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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| 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
| assert sig == crypt.sign_message( | ||
| "/keydir/keyname.pem", msg, passphrase="password" | ||
| ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| assert b"salt" == decrypted | |
| assert b"salt" == decrypted |
Switch
|
@MKLeb Need conflicts resolved and what about @s0undt3ch comments |
|
@dwoz Do we care about crypt ? |
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