def test_delete_rules(mock_Table, mock_Chain): mock_Chain.return_value.rules = ( EMPTY_RULE._replace(target='DROP').to_iptc(), EMPTY_RULE._replace(target='ACCEPT').to_iptc(), EMPTY_RULE._replace( target='REJECT', target_parameters=( ('reject-with', ('icmp-port-unreachable',)), ), ).to_iptc(), ) iptables.delete_rules( 'PAASTA.service', ( EMPTY_RULE._replace(target='ACCEPT'), EMPTY_RULE._replace( target='REJECT', target_parameters=( ('reject-with', ('icmp-port-unreachable',)), ), ), ), ) assert mock_Chain('filter', 'PAASTA.service').delete_rule.mock_calls == [ mock.call(mock_Chain.return_value.rules[1]), mock.call(mock_Chain.return_value.rules[2]), ]
def test_delete_rules(mock_Table, mock_Chain): mock_Chain.return_value.rules = ( EMPTY_RULE._replace(target='DROP').to_iptc(), EMPTY_RULE._replace(target='ACCEPT').to_iptc(), EMPTY_RULE._replace(target='REJECT').to_iptc(), ) iptables.delete_rules('PAASTA.service', ( EMPTY_RULE._replace(target='ACCEPT'), EMPTY_RULE._replace(target='REJECT'), )) assert mock_Chain('filter', 'PAASTA.service').delete_rule.mock_calls == [ mock.call(mock_Chain.return_value.rules[1]), mock.call(mock_Chain.return_value.rules[2]), ]
def test_delete_rules(mock_Table, mock_Chain): mock_Chain.return_value.rules = ( EMPTY_RULE._replace(target="DROP").to_iptc(), EMPTY_RULE._replace(target="ACCEPT").to_iptc(), EMPTY_RULE._replace( target="REJECT", target_parameters=(("reject-with", ("icmp-port-unreachable", )), ), ).to_iptc(), ) iptables.delete_rules( "PAASTA.service", ( EMPTY_RULE._replace(target="ACCEPT"), EMPTY_RULE._replace( target="REJECT", target_parameters=(("reject-with", ("icmp-port-unreachable", )), ), ), ), ) assert mock_Chain("filter", "PAASTA.service").delete_rule.mock_calls == [ mock.call(mock_Chain.return_value.rules[1]), mock.call(mock_Chain.return_value.rules[2]), ]