From c65347b07d1943168da32e778b18d0ce90bd681e Mon Sep 17 00:00:00 2001 From: Justin Anderson Date: Mon, 15 Aug 2016 13:45:13 -0600 Subject: [PATCH 1/2] Fix failing win_firewall_tests --- tests/unit/modules/win_firewall_test.py | 49 ++++++++++++++++++------- 1 file changed, 35 insertions(+), 14 deletions(-) diff --git a/tests/unit/modules/win_firewall_test.py b/tests/unit/modules/win_firewall_test.py index 8b877a145f..f3bfa58c01 100644 --- a/tests/unit/modules/win_firewall_test.py +++ b/tests/unit/modules/win_firewall_test.py @@ -111,8 +111,12 @@ class WinFirewallTestCase(TestCase): mock_cmd = MagicMock(return_value='Ok.') with patch.dict(win_firewall.__salt__, {'cmd.run': mock_cmd}): self.assertTrue(win_firewall.add_rule("test", "1", protocol='icmpv4')) - mock_cmd.assert_called_once_with(['netsh', 'advfirewall', 'firewall', 'add', 'rule', 'name=test', - 'protocol=icmpv4', 'dir=in', 'action=allow'], + mock_cmd.assert_called_once_with(['netsh', 'advfirewall', 'firewall', 'add', 'rule', + 'name=test', + 'protocol=icmpv4', + 'dir=in', + 'action=allow', + 'remoteip=any'], python_shell=False) def test_add_rule_icmp6(self): @@ -122,8 +126,12 @@ class WinFirewallTestCase(TestCase): mock_cmd = MagicMock(return_value='Ok.') with patch.dict(win_firewall.__salt__, {'cmd.run': mock_cmd}): self.assertTrue(win_firewall.add_rule("test", "1", protocol='icmpv6')) - mock_cmd.assert_called_once_with(['netsh', 'advfirewall', 'firewall', 'add', 'rule', 'name=test', - 'protocol=icmpv6', 'dir=in', 'action=allow'], + mock_cmd.assert_called_once_with(['netsh', 'advfirewall', 'firewall', 'add', 'rule', + 'name=test', + 'protocol=icmpv6', + 'dir=in', + 'action=allow', + 'remoteip=any'], python_shell=False) def test_add_rule_icmp4_any(self): @@ -133,8 +141,12 @@ class WinFirewallTestCase(TestCase): mock_cmd = MagicMock(return_value='Ok.') with patch.dict(win_firewall.__salt__, {'cmd.run': mock_cmd}): self.assertTrue(win_firewall.add_rule("test", "1", protocol='icmpv4:any,any')) - mock_cmd.assert_called_once_with(['netsh', 'advfirewall', 'firewall', 'add', 'rule', 'name=test', - 'protocol=icmpv4:any,any', 'dir=in', 'action=allow'], + mock_cmd.assert_called_once_with(['netsh', 'advfirewall', 'firewall', 'add', 'rule', + 'name=test', + 'protocol=icmpv4:any,any', + 'dir=in', + 'action=allow', + 'remoteip=any'], python_shell=False) # 'delete_rule' function tests: 1 @@ -151,8 +163,8 @@ class WinFirewallTestCase(TestCase): 'firewall', 'delete', 'rule', 'name=test', 'protocol=tcp', 'dir=in', - 'localport=8080', - 'remoteip=any'], + 'remoteip=any', + 'localport=8080'], python_shell=False) def test_delete_rule_icmp4(self): @@ -162,8 +174,11 @@ class WinFirewallTestCase(TestCase): mock_cmd = MagicMock(return_value='Ok.') with patch.dict(win_firewall.__salt__, {'cmd.run': mock_cmd}): self.assertTrue(win_firewall.delete_rule("test", "1", protocol='icmpv4')) - mock_cmd.assert_called_once_with(['netsh', 'advfirewall', 'firewall', 'delete', 'rule', 'name=test', - 'protocol=icmpv4', 'dir=in'], + mock_cmd.assert_called_once_with(['netsh', 'advfirewall', 'firewall', 'delete', 'rule', + 'name=test', + 'protocol=icmpv4', + 'dir=in', + 'remoteip=any'], python_shell=False) def test_delete_rule_icmp6(self): @@ -173,8 +188,11 @@ class WinFirewallTestCase(TestCase): mock_cmd = MagicMock(return_value='Ok.') with patch.dict(win_firewall.__salt__, {'cmd.run': mock_cmd}): self.assertTrue(win_firewall.delete_rule("test", "1", protocol='icmpv6')) - mock_cmd.assert_called_once_with(['netsh', 'advfirewall', 'firewall', 'delete', 'rule', 'name=test', - 'protocol=icmpv6', 'dir=in'], + mock_cmd.assert_called_once_with(['netsh', 'advfirewall', 'firewall', 'delete', 'rule', + 'name=test', + 'protocol=icmpv6', + 'dir=in', + 'remoteip=any'], python_shell=False) def test_delete_rule_icmp4_any(self): @@ -184,8 +202,11 @@ class WinFirewallTestCase(TestCase): mock_cmd = MagicMock(return_value='Ok.') with patch.dict(win_firewall.__salt__, {'cmd.run': mock_cmd}): self.assertTrue(win_firewall.delete_rule("test", "1", protocol='icmpv4:any,any')) - mock_cmd.assert_called_once_with(['netsh', 'advfirewall', 'firewall', 'delete', 'rule', 'name=test', - 'protocol=icmpv4:any,any', 'dir=in'], + mock_cmd.assert_called_once_with(['netsh', 'advfirewall', 'firewall', 'delete', 'rule', + 'name=test', + 'protocol=icmpv4:any,any', + 'dir=in', + 'remoteip=any'], python_shell=False) From eb42775a49c29f704a8bb5fbcd5b3e17a0dde77f Mon Sep 17 00:00:00 2001 From: Justin Anderson Date: Mon, 15 Aug 2016 14:44:37 -0600 Subject: [PATCH 2/2] Fix orderering in test_add_rule --- tests/unit/modules/win_firewall_test.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/unit/modules/win_firewall_test.py b/tests/unit/modules/win_firewall_test.py index f3bfa58c01..f41c005002 100644 --- a/tests/unit/modules/win_firewall_test.py +++ b/tests/unit/modules/win_firewall_test.py @@ -100,8 +100,8 @@ class WinFirewallTestCase(TestCase): 'firewall', 'add', 'rule', 'name=test', 'protocol=tcp', 'dir=in', 'action=allow', - 'localport=8080', - 'remoteip=any'], + 'remoteip=any', + 'localport=8080'], python_shell=False) def test_add_rule_icmp4(self):