Resolved merge conflict

This commit is contained in:
Anil Kabra 2017-07-27 13:28:41 -05:00
commit acfc5fb710

View File

@ -120,6 +120,23 @@ class CryptTestCase(TestCase):
crypt.gen_keys('/keydir', 'keyname', 2048)
salt.utils.fopen.assert_has_calls([open_priv_wb, open_pub_wb], any_order=True)
@patch('os.umask', MagicMock())
@patch('os.chmod', MagicMock())
@patch('os.chown', MagicMock())
@patch('os.access', MagicMock(return_value=True))
def test_gen_keys_with_passphrase(self):
with patch('salt.utils.fopen', mock_open()):
open_priv_wb = call('/keydir/keyname.pem', 'wb+')
open_pub_wb = call('/keydir/keyname.pub', 'wb+')
with patch('os.path.isfile', return_value=True):
self.assertEqual(crypt.gen_keys('/keydir', 'keyname', 2048, passphrase='password'), '/keydir/keyname.pem')
self.assertNotIn(open_priv_wb, salt.utils.fopen.mock_calls)
self.assertNotIn(open_pub_wb, salt.utils.fopen.mock_calls)
with patch('os.path.isfile', return_value=False):
with patch('salt.utils.fopen', mock_open()):
crypt.gen_keys('/keydir', 'keyname', 2048)
salt.utils.fopen.assert_has_calls([open_priv_wb, open_pub_wb], any_order=True)
def test_sign_message(self):
key = RSA.importKey(PRIVKEY_DATA)
with patch('salt.crypt._get_rsa_key', return_value=key):
@ -129,6 +146,10 @@ class CryptTestCase(TestCase):
with patch('salt.utils.fopen', mock_open(read_data=PRIVKEY_DATA)):
self.assertEqual(SIG, crypt.sign_message('/keydir/keyname.pem', MSG, passphrase='password'))
def test_sign_message_with_passphrase(self):
with patch('salt.utils.fopen', mock_open(read_data=PRIVKEY_DATA)):
self.assertEqual(SIG, crypt.sign_message('/keydir/keyname.pem', MSG, passphrase='password'))
def test_verify_signature(self):
with patch('salt.utils.files.fopen', mock_open(read_data=PUBKEY_DATA)):
self.assertTrue(crypt.verify_signature('/keydir/keyname.pub', MSG, SIG))