def test_loadbalancer_attributes(self): """ Test LoadBalancer Attributes logic """ rule = Elb() props = { "Type": "network", "LoadBalancerAttributes": [{ "Key": "load_balancing.cross_zone.enabled", "Value": "true" }] } matches = rule.check_loadbalancer_allowed_attributes( props, ['Resources', 'NLB', 'Properties']) self.assertEqual(len(matches), 0) props = { "LoadBalancerAttributes": [{ "Key": "idle_timeout.timeout_seconds", "Value": 60 }, { "Key": "routing.http2.enabled", "Value": "true" }] } matches = rule.check_loadbalancer_allowed_attributes( props, ['Resources', 'ALB', 'Properties']) self.assertEqual(len(matches), 0) props = { "Type": "network", "LoadBalancerAttributes": [{ "Key": "idle_timeout.timeout_seconds", "Value": 60 }, { "Key": "routing.http2.enabled", "Value": "true" }] } matches = rule.check_loadbalancer_allowed_attributes( props, ['Resources', 'NLB', 'Properties']) self.assertEqual(len(matches), 2)
def test_loadbalancer_attributes(self): """ Test LoadBalancer Attributes logic """ rule = Elb() props = { "Type": "network", "LoadBalancerAttributes": [{ "Key": "load_balancing.cross_zone.enabled", "Value": "true" }] } matches = rule.check_loadbalancer_allowed_attributes( props, ['Resources', 'NLB', 'Properties'], {}) self.assertEqual(len(matches), 0) props = { "LoadBalancerAttributes": [{ "Key": "idle_timeout.timeout_seconds", "Value": 60 }, { "Key": "routing.http2.enabled", "Value": "true" }] } matches = rule.check_loadbalancer_allowed_attributes( props, ['Resources', 'ALB', 'Properties'], {}) self.assertEqual(len(matches), 0) props = { "Type": "network", "LoadBalancerAttributes": [{ "Key": "idle_timeout.timeout_seconds", "Value": 60 }, { "Key": "routing.http2.enabled", "Value": "true" }] } matches = rule.check_loadbalancer_allowed_attributes( props, ['Resources', 'LB', 'Properties'], {}) self.assertEqual(len(matches), 2) props = {"Type": "network"} elb_type = rule.get_loadbalancer_type(props) self.assertEqual(elb_type, 'network') props = {"Type": "application"} elb_type = rule.get_loadbalancer_type(props) self.assertEqual(elb_type, 'application') props = {} elb_type = rule.get_loadbalancer_type(props) self.assertEqual(elb_type, 'application') props = {"Type": {"Ref": "LoadBalancerType"}} elb_type = rule.get_loadbalancer_type(props) self.assertEqual(elb_type, None)