"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "tests/unit/cloud/clouds/test_ec2.py" between
salt-2019.2.0.tar.gz and salt-2019.2.1.tar.gz

About: SaltStack is a systems management software for data center automation, cloud orchestration, server provisioning, configuration management and more. Community version.

test_ec2.py  (salt-2019.2.0):test_ec2.py  (salt-2019.2.1)
skipping to change at line 68 skipping to change at line 68
self.assertTrue(ec2._validate_key_path_and_mode('key_file')) self.assertTrue(ec2._validate_key_path_and_mode('key_file'))
type(patched_stat.return_value).st_mode = PropertyMock(return_va lue=0o400) type(patched_stat.return_value).st_mode = PropertyMock(return_va lue=0o400)
self.assertTrue(ec2._validate_key_path_and_mode('key_file')) self.assertTrue(ec2._validate_key_path_and_mode('key_file'))
# Key file does not exist # Key file does not exist
with patch('os.path.exists', return_value=False): with patch('os.path.exists', return_value=False):
self.assertRaises( self.assertRaises(
SaltCloudSystemExit, ec2._validate_key_path_and_mode, 'key_file' ) SaltCloudSystemExit, ec2._validate_key_path_and_mode, 'key_file' )
@skipIf(not ec2.HAS_M2 and not ec2.HAS_PYCRYPTO, 'Needs crypto library')
@patch('salt.cloud.clouds.ec2._get_node') @patch('salt.cloud.clouds.ec2._get_node')
@patch('salt.cloud.clouds.ec2.get_location') @patch('salt.cloud.clouds.ec2.get_location')
@patch('salt.cloud.clouds.ec2.get_provider') @patch('salt.cloud.clouds.ec2.get_provider')
@patch('salt.utils.aws.query') @patch('salt.utils.aws.query')
def test_get_password_data(self, query, get_provider, get_location, _get_nod e): def test_get_password_data(self, query, get_provider, get_location, _get_nod e):
query.return_value = [ query.return_value = [
{ {
'passwordData': PASS_DATA 'passwordData': PASS_DATA
} }
] ]
_get_node.return_value = {'instanceId': 'i-abcdef'} _get_node.return_value = {'instanceId': 'i-abcdef'}
get_location.return_value = 'us-west2' get_location.return_value = 'us-west2'
get_provider.return_value = 'ec2' get_provider.return_value = 'ec2'
with salt.utils.files.fopen(self.key_file, 'w') as fp: with salt.utils.files.fopen(self.key_file, 'w') as fp:
fp.write(PRIVKEY_DATA) fp.write(PRIVKEY_DATA)
ret = ec2.get_password_data( ret = ec2.get_password_data(
name='i-abcddef', kwargs={'key_file': self.key_file}, call='action' name='i-abcddef', kwargs={'key_file': self.key_file}, call='action'
) )
assert ret['passwordData'] == PASS_DATA assert ret['passwordData'] == PASS_DATA
assert ret['password'] == 'testp4ss!' assert ret['password'] == 'testp4ss!'
@patch('salt.cloud.clouds.ec2.config.get_cloud_config_value')
@patch('salt.cloud.clouds.ec2.get_location')
@patch('salt.cloud.clouds.ec2.get_provider')
@patch('salt.cloud.clouds.ec2.aws.query')
def test_get_imageid(self, aws_query, get_provider, get_location, config):
'''
test querying imageid function
'''
vm = {}
ami = 'ami-1234'
config.return_value = 'test/*'
get_location.return_value = 'us-west2'
get_provider.return_value = 'ec2'
aws_query.return_value = [{'imageId': ami}]
# test image filter
self.assertEqual(ec2.get_imageid(vm), ami)
# test ami-image
config.return_value = ami
self.assertEqual(ec2.get_imageid(vm), ami)
# we should have only ran aws.query once when testing the aws filter
aws_query.assert_called_once()
 End of changes. 2 change blocks. 
0 lines changed or deleted 1 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)