Merge pull request #41882 from Ch3LL/fix_crypt_test

Add pycryptodome to crypt_test
This commit is contained in:
garethgreenaway 2017-06-21 12:51:09 -07:00 committed by GitHub
commit 4a326444fe

View file

@ -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))