|
|
@@ -161,14 +161,15 @@ class CloudSecurityServiceTestCase(ProviderTestBase):
|
|
|
with helpers.cleanup_action(lambda: sg.delete()):
|
|
|
sg.add_rule(ip_protocol='tcp', from_port=1111, to_port=1111,
|
|
|
cidr_ip='0.0.0.0/0')
|
|
|
- found_rules = [rule for rule in sg.rules if
|
|
|
- rule.cidr_ip == '0.0.0.0/0' and
|
|
|
- rule.ip_protocol == 'tcp' and
|
|
|
- rule.from_port == 1111 and
|
|
|
- rule.to_port == 1111]
|
|
|
+ rule = sg.get_rule(ip_protocol='tcp', from_port=1111, to_port=1111,
|
|
|
+ cidr_ip='0.0.0.0/0')
|
|
|
self.assertTrue(
|
|
|
- len(found_rules) == 1,
|
|
|
- "Expected rule not found in security group: {0}".format(name))
|
|
|
+ (rule.ip_protocol == 'tcp' and
|
|
|
+ rule.from_port == 1111 and
|
|
|
+ rule.to_port == 1111 and
|
|
|
+ rule.cidr_ip == '0.0.0.0/0'),
|
|
|
+ "Expected rule {0} not found in security group: {0}".format(
|
|
|
+ rule, sg.rules))
|
|
|
|
|
|
object_keys = (
|
|
|
sg.rules[0].ip_protocol,
|
|
|
@@ -187,8 +188,8 @@ class CloudSecurityServiceTestCase(ProviderTestBase):
|
|
|
"The same security groups should still be equal?")
|
|
|
json_repr = json.dumps(
|
|
|
{"description": name, "name": name, "id": sg.id, "rules":
|
|
|
- [{"from_port": 1111, "group": "", "cidr_ip": "0.0.0.0/0",
|
|
|
- "parent": sg.id, "to_port": 1111, "ip_protocol": "tcp",
|
|
|
+ [{"from_port": "1111", "group": "", "cidr_ip": "0.0.0.0/0",
|
|
|
+ "parent": sg.id, "to_port": "1111", "ip_protocol": "tcp",
|
|
|
"id": sg.rules[0].id}]},
|
|
|
sort_keys=True)
|
|
|
self.assertTrue(
|
|
|
@@ -213,13 +214,12 @@ class CloudSecurityServiceTestCase(ProviderTestBase):
|
|
|
len(sg.rules) == 0,
|
|
|
"Expected no security group group rule. Got {0}."
|
|
|
.format(sg.rules))
|
|
|
- sg.add_rule(src_group=sg)
|
|
|
+ rule = sg.add_rule(src_group=sg)
|
|
|
self.assertTrue(
|
|
|
- sg.rules[0].group.name == name,
|
|
|
+ rule.group.name == name,
|
|
|
"Expected security group rule name {0}. Got {1}."
|
|
|
- .format(name, sg.rules[0].group.name))
|
|
|
- sg.rules[0].delete()
|
|
|
- sg = self.provider.security.security_groups.get(sg.id) # update
|
|
|
+ .format(name, rule.group.name))
|
|
|
+ rule.delete()
|
|
|
self.assertTrue(
|
|
|
len(sg.rules) == 0,
|
|
|
"Deleting SecurityGroupRule should delete it: {0}".format(
|