Ejemplo n.º 1
0
 def test_normal(
         self, mark_id, source, destination, chain, protocol, line_number,
         expected):
     mark = IptablesMangleMark(
         mark_id=mark_id, source=_DEF_SRC, destination=_DEF_DST,
         chain=chain, protocol=protocol, line_number=line_number)
     assert mark.to_delete_command() == expected
Ejemplo n.º 2
0
 def test_normal(
         self, mark_id, source, destination, chain, protocol, line_number,
         expected):
     mark = IptablesMangleMark(
         mark_id=mark_id, source=source, destination=destination,
         chain=chain, protocol=protocol, line_number=line_number)
     assert mark.to_append_command() == expected
Ejemplo n.º 3
0
 def test_exception(
         self, mark_id, source, destination, chain, protocol, line_number,
         expected):
     mark = IptablesMangleMark(
         mark_id=mark_id, source=source, destination=destination,
         chain=chain, protocol=protocol, line_number=line_number)
     with pytest.raises(expected):
         mark.to_delete_command()
Ejemplo n.º 4
0
 def test_normal(self, mark_id, source, destination, chain, protocol, line_number, expected):
     mark = IptablesMangleMark(
         mark_id=mark_id,
         source=_DEF_SRC,
         destination=_DEF_DST,
         chain=chain,
         protocol=protocol,
         line_number=line_number,
     )
     assert mark.to_delete_command() == expected
Ejemplo n.º 5
0
 def test_normal(self, mark_id, source, destination, chain, protocol, line_number, expected):
     mark = IptablesMangleMark(
         mark_id=mark_id,
         source=source,
         destination=destination,
         chain=chain,
         protocol=protocol,
         line_number=line_number,
     )
     assert mark.to_append_command() == expected
Ejemplo n.º 6
0
 def test_exception(self, mark_id, source, destination, chain, protocol, line_number, expected):
     mark = IptablesMangleMark(
         mark_id=mark_id,
         source=source,
         destination=destination,
         chain=chain,
         protocol=protocol,
         line_number=line_number,
     )
     with pytest.raises(expected):
         mark.to_delete_command()
Ejemplo n.º 7
0
    def test_normal(self):
        for i in range(5):
            mark_id = IptablesMangleController.get_unique_mark_id()

            assert mark_id == (i + 1)
            mangle_mark = IptablesMangleMark(
                mark_id=mark_id,
                source=_DEF_SRC,
                destination=_DEF_DST,
                chain=random.choice(VALID_CHAIN_LIST))
            assert IptablesMangleController.add(mangle_mark) == 0
Ejemplo n.º 8
0
    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 = IptablesMangleMark(
                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
Ejemplo n.º 9
0
import random

import pytest
from subprocrunner import SubprocessRunner

from tcconfig._iptables import VALID_CHAIN_LIST
from tcconfig._iptables import IptablesMangleMark
from tcconfig._iptables import IptablesMangleController

_DEF_SRC = "192.168.0.0/24"
_DEF_DST = "192.168.100.0/24"

prerouting_mangle_mark_list = [
    IptablesMangleMark(line_number=1,
                       mark_id=1,
                       source=_DEF_SRC,
                       destination=_DEF_DST,
                       chain="PREROUTING",
                       protocol="all"),
]

input_mangle_mark_list = [
    IptablesMangleMark(line_number=1,
                       mark_id=1234,
                       source="anywhere",
                       destination=_DEF_DST,
                       chain="INPUT",
                       protocol="all"),
]

output_mangle_mark_list = [
    IptablesMangleMark(line_number=1,