Commit e87c79ab authored by Sigmund Augdal's avatar Sigmund Augdal

Added unit test for cidr rules and tcp protocol

parent 67dde28f
......@@ -44,6 +44,27 @@ class TestProcessSecurityGroup(object):
self.generator.add_ipset_net.assert_has_calls([mock.call('rls_cidr_to_ip1', '10.0.0.1/32'),
mock.call('rls_cidr_to_ip1', '10.0.0.2/32')], True)
@mock.patch('nova_router.security_groups.get_group_members')
@mock.patch('nova_router.security_groups.get_group_mode')
@mock.patch('nova_router.security_groups.get_group_rules')
def test_cidr_tcp_protocol(self, get_group_rules, get_group_mode, get_group_members):
get_group_members.return_value = ['00:11:22:33:44:55', ['00:11:22:33:44:55']]
get_group_mode.return_value = "closed"
get_group_rules.return_value = [
{
'id': 1,
'protocol': 'tcp',
'source_type': 'cidr',
'source_cidr': '10.0.0.1/32',
'destination_port': 22,
},
]
self.generator.add_ipset_member = mock.MagicMock(wraps=self.generator.add_ipset_member)
self.generator.process_security_group("a", "b")
self.generator.add_ipset_member.assert_called_with(iptables_configurator.RULES_FROM_CIDR,
"00:11:22:33:44:55", "tcp", 22,
"10.0.0.1/32")
@mock.patch('nova_router.security_groups.get_group_members')
@mock.patch('nova_router.security_groups.get_group_mode')
@mock.patch('nova_router.security_groups.get_group_rules')
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment