mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Merge pull request #41882 from Ch3LL/fix_crypt_test
Add pycryptodome to crypt_test
This commit is contained in:
commit
4a326444fe
1 changed files with 8 additions and 2 deletions
|
@ -16,10 +16,16 @@ from salt import crypt
|
|||
|
||||
# third-party libs
|
||||
try:
|
||||
import Crypto.PublicKey.RSA # pylint: disable=unused-import
|
||||
from Cryptodome.PublicKey import RSA # pylint: disable=unused-import
|
||||
HAS_PYCRYPTO_RSA = True
|
||||
except ImportError:
|
||||
HAS_PYCRYPTO_RSA = False
|
||||
if not HAS_PYCRYPTO_RSA:
|
||||
try:
|
||||
from Crypto.PublicKey import RSA
|
||||
HAS_PYCRYPTO_RSA = True
|
||||
except ImportError:
|
||||
HAS_PYCRYPTO_RSA = False
|
||||
|
||||
|
||||
PRIVKEY_DATA = (
|
||||
|
@ -101,7 +107,7 @@ class CryptTestCase(TestCase):
|
|||
salt.utils.fopen.assert_has_calls([open_priv_wb, open_pub_wb], any_order=True)
|
||||
|
||||
def test_sign_message(self):
|
||||
key = Crypto.PublicKey.RSA.importKey(PRIVKEY_DATA)
|
||||
key = RSA.importKey(PRIVKEY_DATA)
|
||||
with patch('salt.crypt._get_rsa_key', return_value=key):
|
||||
self.assertEqual(SIG, salt.crypt.sign_message('/keydir/keyname.pem', MSG))
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue