def test_normal(self, mark_id, source, destination, chain, protocol, line_number, expected): mark = IptablesMangleMarkEntry(ip_version=4, mark_id=mark_id, source=_DEF_SRC, destination=_DEF_DST, chain=chain, protocol=protocol, line_number=line_number) assert mark.to_delete_command() == expected
def test_normal(self, mark_id, source, destination, chain, protocol, line_number, expected): mark = IptablesMangleMarkEntry( ip_version=4, mark_id=mark_id, source=source, destination=destination, chain=chain, protocol=protocol, line_number=line_number, ) assert mark.to_append_command() == expected
def test_exception(self, mark_id, source, destination, chain, protocol, line_number, expected): mark = IptablesMangleMarkEntry(ip_version=4, mark_id=mark_id, source=source, destination=destination, chain=chain, protocol=protocol, line_number=line_number) with pytest.raises(expected): mark.to_delete_command()
def test_normal(self, iptables_ctrl_ipv4): iptables_ctrl_ipv4.clear() for i in range(5): mark_id = iptables_ctrl_ipv4.get_unique_mark_id() assert mark_id == (i + 101) mangle_mark = IptablesMangleMarkEntry( ip_version=4, mark_id=mark_id, source=_DEF_SRC, destination=_DEF_DST, chain=random.choice(VALID_CHAIN_LIST)) assert iptables_ctrl_ipv4.add(mangle_mark) == 0
import pytest from tcconfig._common import find_bin_path from tcconfig._iptables import ( VALID_CHAIN_LIST, IptablesMangleController, IptablesMangleMarkEntry, get_iptables_base_command) _DEF_SRC = "192.168.0.0/24" _DEF_DST = "192.168.100.0/24" prerouting_mangle_mark_list = [ IptablesMangleMarkEntry( ip_version=4, line_number=1, mark_id=1, source=_DEF_SRC, destination=_DEF_DST, chain="PREROUTING", protocol="all"), ] input_mangle_mark_list = [ IptablesMangleMarkEntry( ip_version=4, line_number=1, mark_id=1234, source="anywhere", destination=_DEF_DST, chain="INPUT", protocol="all"), ] output_mangle_mark_list = [