예제 #1
0
def test_open_port_tcp_no_comment(location, system_context):
    ipt.install_rules(location, system_context)

    ipt.open_port(system_context, 4242, protocol="tcp", comment="test port")

    _validate_rules_files(system_context,
                          "-A TCP -p tcp -m tcp --dport 4242 -j ACCEPT")
예제 #2
0
def test_open_port_udp_no_comment(location, system_context):
    ipt.install_rules(location, system_context)

    ipt.open_port(system_context, 4242, protocol="udp")

    _validate_rules_files(system_context,
                          "-A UDP -p udp -m udp --dport 4242 -j ACCEPT")
예제 #3
0
def test_open_port_udp(location, system_context):
    ipt.install_rules(location, system_context)

    ipt.open_port(system_context, 4242, protocol='udp', comment='test port')

    _validate_rules_files(system_context, '# test port:',
                          '-A UDP -p udp -m udp --dport 4242 -j ACCEPT')
예제 #4
0
def test_open_port_default_no_comment(location, system_context):
    ipt.install_rules(location, system_context)

    ipt.open_port(system_context, 4242)

    _validate_rules_files(system_context,
                          "-A TCP -p tcp -m tcp --dport 4242 -j ACCEPT")
예제 #5
0
def test_open_port_default(location, system_context):
    ipt.install_rules(location, system_context)

    ipt.open_port(system_context, 4242, comment='test port')

    _validate_rules_files(system_context, '# test port:',
                          '-A TCP -p tcp -m tcp --dport 4242 -j ACCEPT')
예제 #6
0
def test_interface_forward_no_comment(location, system_context):
    ipt.install_rules(location, system_context)

    ipt.forward_interface(system_context, 've-testiface')

    _validate_rules_files(
        system_context, '-A FORWARD -i ve-testiface -j ACCEPT',
        '-A FORWARD -o ve-testiface -m conntrack '
        '--ctstate RELATED,ESTABLISHED -j ACCEPT')
예제 #7
0
def test_interface_forward(location, system_context):
    ipt.install_rules(location, system_context)

    ipt.forward_interface(system_context, "ve-testiface", comment="test iface")

    _validate_rules_files(
        system_context,
        "# test iface:",
        "-A FORWARD -i ve-testiface -j ACCEPT",
        "-A FORWARD -o ve-testiface -m conntrack "
        "--ctstate RELATED,ESTABLISHED -j ACCEPT",
    )
예제 #8
0
 def __call__(self, location: Location, system_context: SystemContext,
              *args: typing.Any, **kwargs: typing.Any) -> None:
     """Execute command."""
     install_rules(location, system_context)
예제 #9
0
def test_create_iptables_rules(location, system_context):
    ipt.install_rules(location, system_context)

    _validate_rules_files(system_context, "-A FORWARD -j LOGDROP",
                          "-A INPUT -j LOGDROP", "COMMIT")
예제 #10
0
def test_interface_no_double_entries(location, system_context):
    ipt.install_rules(location, system_context)

    ipt.forward_interface(system_context, "ve-testiface", comment="test iface")
    with pytest.raises(GenerateError):
        ipt.forward_interface(system_context, "ve-testiface")