Esempio n. 1
0
    def test_add_snat_rule(self):
        """Test snat rule addition."""
        iptables.add_snat_rule(firewall.SNATRule(proto='tcp',
                                                 src_ip='1.1.1.1',
                                                 src_port=123,
                                                 new_ip='2.2.2.2',
                                                 new_port=345),
                               'SOME_RULE',
                               safe=True)

        treadmill.iptables.add_raw_rule.assert_called_with(
            'nat', 'SOME_RULE',
            ('-s 1.1.1.1 -d 0.0.0.0/0 -p tcp -m tcp --sport 123'
             ' -j SNAT --to-source 2.2.2.2:345'), True)
Esempio n. 2
0
    def test_add_snat_rule(self):
        """Test snat rule addition."""
        iptables.add_snat_rule(
            firewall.SNATRule('tcp',
                              '1.1.1.1', 123,
                              '2.2.2.2', 345),
            'SOME_RULE',
            safe=True
        )

        treadmill.iptables.add_raw_rule.assert_called_with(
            'nat', 'SOME_RULE',
            ('-d 1.1.1.1 -p tcp -m tcp --dport 123'
             ' -j SNAT --to 2.2.2.2:345'),
            True
        )