diff options
author | Ćukasz 'sil2100' Zemczak <lukasz.zemczak@ubuntu.com> | 2018-02-15 14:28:59 +0100 |
---|---|---|
committer | usd-importer <ubuntu-server@lists.ubuntu.com> | 2018-02-15 19:08:29 +0000 |
commit | 3afbcfff2f6e3faf50c0dffee55e7c48b50755b5 (patch) | |
tree | 44d4a5d80868fe6a8defe57f6cc9c21feae59a03 /tests/common/osutil/test_default.py | |
parent | 6c9cd7e1ac55aae259d8e2f06569375e27a12f20 (diff) | |
parent | 7e7d885433a2bac56ce2361126bf7ec3d565fd66 (diff) | |
download | vyos-walinuxagent-3afbcfff2f6e3faf50c0dffee55e7c48b50755b5.tar.gz vyos-walinuxagent-3afbcfff2f6e3faf50c0dffee55e7c48b50755b5.zip |
Import patches-applied version 2.2.21+really2.2.20-0ubuntu1~16.04.1 to applied/ubuntu/xenial-proposed
Imported using git-ubuntu import.
Changelog parent: 6c9cd7e1ac55aae259d8e2f06569375e27a12f20
Unapplied parent: 7e7d885433a2bac56ce2361126bf7ec3d565fd66
New changelog entries:
* Backport bionic version to xenial.
* Revert to an older upstream release: 2.2.20 (LP: #1749589).
- Rename upstream tarball to 2.2.21+really2.2.20 to end up with a
temporarily higher version number than what's in the archive.
* debian/patches/disable_import_test.patch: refreshed patch.
Diffstat (limited to 'tests/common/osutil/test_default.py')
-rw-r--r-- | tests/common/osutil/test_default.py | 55 |
1 files changed, 6 insertions, 49 deletions
diff --git a/tests/common/osutil/test_default.py b/tests/common/osutil/test_default.py index c9fa1de..a73f4b4 100644 --- a/tests/common/osutil/test_default.py +++ b/tests/common/osutil/test_default.py @@ -516,16 +516,6 @@ Match host 192.168.1.2\n\ self.assertEqual(-1, util.get_firewall_dropped_packets("not used")) @patch('azurelinuxagent.common.utils.shellutil.run_get_output') - def test_get_firewall_dropped_packets_transient_error_ignored(self, mock_output): - osutil._enable_firewall = True - util = osutil.DefaultOSUtil() - - mock_output.side_effect = [ - (0, "iptables v{0}".format(osutil.IPTABLES_LOCKING_VERSION)), - (3, "can't initialize iptables table `security': iptables who? (do you need to insmod?)")] - self.assertEqual(0, util.get_firewall_dropped_packets("not used")) - - @patch('azurelinuxagent.common.utils.shellutil.run_get_output') def test_get_firewall_dropped_packets(self, mock_output): osutil._enable_firewall = True util = osutil.DefaultOSUtil() @@ -648,34 +638,6 @@ Chain OUTPUT (policy ACCEPT 104 packets, 43628 bytes) ]) self.assertFalse(osutil._enable_firewall) - @patch('azurelinuxagent.common.utils.shellutil.run_get_output') - @patch('azurelinuxagent.common.utils.shellutil.run') - def test_enable_firewall_checks_for_invalid_iptables_options(self, mock_run, mock_output): - osutil._enable_firewall = True - util = osutil.DefaultOSUtil() - - dst = '1.2.3.4' - version = "iptables v{0}".format(osutil.IPTABLES_LOCKING_VERSION) - wait = "-w" - - # iptables uses the following exit codes - # 0 - correct function - # 1 - other errors - # 2 - errors which appear to be caused by invalid or abused command - # line parameters - mock_run.side_effect = [2] - mock_output.return_value = (0, version) - - self.assertFalse(util.enable_firewall(dst_ip='1.2.3.4', uid=42)) - self.assertFalse(osutil._enable_firewall) - - mock_run.assert_has_calls([ - call(osutil.FIREWALL_DROP.format(wait, "C", dst), chk_err=False), - ]) - mock_output.assert_has_calls([ - call(osutil.IPTABLES_VERSION) - ]) - @patch('os.getuid', return_value=42) @patch('azurelinuxagent.common.utils.shellutil.run_get_output') @patch('azurelinuxagent.common.utils.shellutil.run') @@ -708,15 +670,12 @@ Chain OUTPUT (policy ACCEPT 104 packets, 43628 bytes) version = "iptables v{0}".format(osutil.IPTABLES_LOCKING_VERSION) wait = "-w" - mock_run.side_effect = [0, 1, 0, 1] + mock_run.side_effect = [0, 0] mock_output.side_effect = [(0, version), (0, "Output")] - self.assertTrue(util.remove_firewall(dst, uid)) + self.assertTrue(util.remove_firewall()) mock_run.assert_has_calls([ - call(osutil.FIREWALL_DELETE_CONNTRACK.format(wait, dst), chk_err=False), - call(osutil.FIREWALL_DELETE_CONNTRACK.format(wait, dst), chk_err=False), - call(osutil.FIREWALL_DELETE_OWNER.format(wait, dst, uid), chk_err=False), - call(osutil.FIREWALL_DELETE_OWNER.format(wait, dst, uid), chk_err=False), + call(osutil.FIREWALL_FLUSH.format(wait), chk_err=True) ]) mock_output.assert_has_calls([ call(osutil.IPTABLES_VERSION) @@ -730,17 +689,15 @@ Chain OUTPUT (policy ACCEPT 104 packets, 43628 bytes) osutil._enable_firewall = True util = osutil.DefaultOSUtil() - dst_ip='1.2.3.4' - uid=42 version = "iptables v{0}".format(osutil.IPTABLES_LOCKING_VERSION) wait = "-w" - mock_run.side_effect = [2] + mock_run.side_effect = [1, 0] mock_output.side_effect = [(0, version), (1, "Output")] - self.assertFalse(util.remove_firewall(dst_ip, uid)) + self.assertFalse(util.remove_firewall()) mock_run.assert_has_calls([ - call(osutil.FIREWALL_DELETE_CONNTRACK.format(wait, dst_ip), chk_err=False), + call(osutil.FIREWALL_FLUSH.format(wait), chk_err=True) ]) mock_output.assert_has_calls([ call(osutil.IPTABLES_VERSION) |