summaryrefslogtreecommitdiff
path: root/tests/common/osutil/test_default.py
diff options
context:
space:
mode:
authorƁukasz 'sil2100' Zemczak <lukasz.zemczak@ubuntu.com>2017-09-15 12:42:50 +0200
committerusd-importer <ubuntu-server@lists.ubuntu.com>2017-09-15 11:48:27 +0000
commit6aaeb3237653102b5a376986f0ea73327a7a4379 (patch)
tree6c6acf3151ea39557db106a1202a7763aef8a530 /tests/common/osutil/test_default.py
parent185ceb32fea5d5c2a43d7b6ee2a40228489055f4 (diff)
downloadvyos-walinuxagent-6aaeb3237653102b5a376986f0ea73327a7a4379.tar.gz
vyos-walinuxagent-6aaeb3237653102b5a376986f0ea73327a7a4379.zip
Import patches-unapplied version 2.2.17-0ubuntu1 to ubuntu/artful-proposed
Imported using git-ubuntu import. Changelog parent: 185ceb32fea5d5c2a43d7b6ee2a40228489055f4 New changelog entries: * New upstream release (LP: #1717306).
Diffstat (limited to 'tests/common/osutil/test_default.py')
-rw-r--r--tests/common/osutil/test_default.py25
1 files changed, 24 insertions, 1 deletions
diff --git a/tests/common/osutil/test_default.py b/tests/common/osutil/test_default.py
index ec4408b..08125ae 100644
--- a/tests/common/osutil/test_default.py
+++ b/tests/common/osutil/test_default.py
@@ -602,7 +602,6 @@ Match host 192.168.1.2\n\
dst = '1.2.3.4'
uid = 42
version = "iptables v{0}".format(osutil.IPTABLES_LOCKING_VERSION)
- wait = "-w"
mock_run.side_effect = [1, 0, 0]
mock_output.side_effect = [(0, version), (0, "Output")]
@@ -613,5 +612,29 @@ Match host 192.168.1.2\n\
mock_uid.assert_not_called()
self.assertFalse(osutil._enable_firewall)
+ @patch('os.getuid', return_value=42)
+ @patch('azurelinuxagent.common.utils.shellutil.run_get_output')
+ @patch('azurelinuxagent.common.utils.shellutil.run')
+ def test_remove_firewall(self, mock_run, mock_output, mock_uid):
+ osutil._enable_firewall = True
+ util = osutil.DefaultOSUtil()
+
+ dst = '1.2.3.4'
+ uid = 42
+ version = "iptables v{0}".format(osutil.IPTABLES_LOCKING_VERSION)
+ wait = "-w"
+
+ mock_run.side_effect = [0, 0]
+ mock_output.side_effect = [(0, version), (0, "Output")]
+ self.assertTrue(util.remove_firewall())
+
+ mock_run.assert_has_calls([
+ call(osutil.FIREWALL_FLUSH.format(wait), chk_err=False)
+ ])
+ mock_output.assert_has_calls([
+ call(osutil.IPTABLES_VERSION)
+ ])
+ self.assertTrue(osutil._enable_firewall)
+
if __name__ == '__main__':
unittest.main()