예제 #1
0
    def test__get_current_snat_rules(self):
        """Test query DNAT/SNAT rules."""
        # Disable protected-access: Test access protected members.
        # pylint: disable=protected-access
        treadmill.subproc.check_output.return_value = \
            self.nat_table_save

        rules = iptables._get_current_snat_rules(iptables.POSTROUTING_SNAT)

        treadmill.subproc.check_output.assert_called_with(
            ['iptables', '-t', 'nat', '-S', iptables.POSTROUTING_SNAT])
        self.assertEqual(set(rules), self.snat_rules)
예제 #2
0
    def test__get_current_snat_rules(self):
        """Test query DNAT/SNAT rules."""
        # Disable W0212: Test access protected members.
        # pylint: disable=W0212
        treadmill.subproc.check_output.return_value = \
            open(self.NAT_TABLE_SAVE).read()

        rules = iptables._get_current_snat_rules(iptables.POSTROUTING_SNAT)

        treadmill.subproc.check_output.assert_called_with(
            ['iptables',
             '-t', 'nat', '-S', iptables.POSTROUTING_SNAT]
        )
        self.assertEquals(set(rules), self.snat_rules)