def test_delete_passthrough_rule(self): """Test deletion of a passthrough rule""" iptables.delete_passthrough_rule( firewall.PassThroughRule(src_ip='4.4.4.4', dst_ip='1.2.3.4'), iptables.PREROUTING_PASSTHROUGH) treadmill.iptables.delete_raw_rule.assert_called_with( 'nat', iptables.PREROUTING_PASSTHROUGH, '-s 4.4.4.4 -j DNAT --to-destination 1.2.3.4')
def test_delete_passthrough_rule2(self): """Test deletion of a passthrough rule (no conntrack data)""" # Check that ret_code 1 from conntrack -D is treated as success. iptables.delete_passthrough_rule( firewall.PassThroughRule(src_ip='5.5.5.5', dst_ip='1.2.3.4'), iptables.PREROUTING_PASSTHROUGH) treadmill.iptables.delete_raw_rule.assert_called_with( 'nat', iptables.PREROUTING_PASSTHROUGH, '-s 5.5.5.5 -j DNAT --to-destination 1.2.3.4')