diff --git a/moto/ec2/models.py b/moto/ec2/models.py index 73b16be3d..5b1f5a1d6 100644 --- a/moto/ec2/models.py +++ b/moto/ec2/models.py @@ -377,7 +377,7 @@ class SecurityGroupBackend(object): # 2 levels of chaining necessary since it's a complex structure all_groups = itertools.chain.from_iterable([x.values() for x in self.groups.values()]) - for group in itertools.chain(all_groups): + for group in all_groups: if group.id == group_id: return group @@ -452,7 +452,7 @@ class SecurityGroupBackend(object): source_group = self.get_security_group_from_id(source_group_id) if source_group: source_groups.append(source_group) - + security_rule = SecurityRule(ip_protocol, from_port, to_port, ip_ranges, source_groups) if security_rule in group.ingress_rules: group.ingress_rules.remove(security_rule) diff --git a/tests/test_ec2/test_security_groups.py b/tests/test_ec2/test_security_groups.py index fe330e17f..27d523e41 100644 --- a/tests/test_ec2/test_security_groups.py +++ b/tests/test_ec2/test_security_groups.py @@ -142,6 +142,8 @@ def test_authorize_group_in_vpc(): security_group2 = conn.create_security_group('test2', 'test2', vpc_id) success = security_group1.authorize(ip_protocol="tcp", from_port="22", to_port="2222", src_group=security_group2) + success.should.be.true success = security_group1.revoke(ip_protocol="tcp", from_port="22", to_port="2222", src_group=security_group2) + success.should.be.true