Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_validate_security_group_count_empty(self):
blueprint = ElasticFileSystem('test_efs_ElasticFileSystem', self.ctx)
variables = EFS_VARIABLES.copy()
variables['SecurityGroups'] = {}
variables['ExtraSecurityGroups'] = []
with self.assertRaises(ValidatorError):
blueprint.resolve_variables(
[Variable(k, v) for k, v in variables.items()])
def test_validate_subnets_ip_addresses_unmatching(self):
blueprint = ElasticFileSystem('test_efs_ElasticFileSystem', self.ctx)
variables = EFS_VARIABLES.copy()
variables['IpAddresses'] = ['172.16.1.10']
with self.assertRaises(ValidatorError):
blueprint.resolve_variables(
[Variable(k, v) for k, v in variables.items()])
def validate_efs_subnets(self):
validator = '{}.{}'.format(type(self).__name__, 'validate_efs_subnets')
v = self.get_variables()
subnet_count = len(v['Subnets'])
if not subnet_count:
raise ValidatorError(
'Subnets', validator, v['Subnets'],
'At least one Subnet must be provided')
ip_count = len(v['IpAddresses'])
if ip_count and ip_count != subnet_count:
raise ValidatorError(
'IpAddresses', validator, v['IpAddresses'],
'The number of IpAddresses must match the number of Subnets')
def validate_efs_security_groups(self):
validator = '{}.{}'.format(type(self).__name__,
'validate_efs_security_groups')
v = self.get_variables()
count = len(v['SecurityGroups'] or []) + len(v['ExtraSecurityGroups'])
if count == 0:
raise ValidatorError(
'SecurityGroups,ExtraSecurityGroups', validator, count,
'At least one SecurityGroup must be provided')
elif count > 5:
raise ValidatorError(
'SecurityGroups,ExtraSecurityGroups', validator, count,
'At most five total SecurityGroups must be provided')
def validate_efs_subnets(self):
validator = '{}.{}'.format(type(self).__name__, 'validate_efs_subnets')
v = self.get_variables()
subnet_count = len(v['Subnets'])
if not subnet_count:
raise ValidatorError(
'Subnets', validator, v['Subnets'],
'At least one Subnet must be provided')
ip_count = len(v['IpAddresses'])
if ip_count and ip_count != subnet_count:
raise ValidatorError(
'IpAddresses', validator, v['IpAddresses'],
'The number of IpAddresses must match the number of Subnets')
def validate_efs_security_groups(self):
validator = '{}.{}'.format(type(self).__name__,
'validate_efs_security_groups')
v = self.get_variables()
count = len(v['SecurityGroups'] or []) + len(v['ExtraSecurityGroups'])
if count == 0:
raise ValidatorError(
'SecurityGroups,ExtraSecurityGroups', validator, count,
'At least one SecurityGroup must be provided')
elif count > 5:
raise ValidatorError(
'SecurityGroups,ExtraSecurityGroups', validator, count,
'At most five total SecurityGroups must be provided')