Merge pull request #35465 from jtand/fix_win_firewall_test

Fix failing win_firewall_tests
This commit is contained in:
Mike Place 2016-08-16 10:26:11 +09:00 committed by GitHub
commit 3a5ae3f3e2

View File

@ -100,8 +100,8 @@ class WinFirewallTestCase(TestCase):
'firewall', 'add', 'rule', 'firewall', 'add', 'rule',
'name=test', 'protocol=tcp', 'name=test', 'protocol=tcp',
'dir=in', 'action=allow', 'dir=in', 'action=allow',
'localport=8080', 'remoteip=any',
'remoteip=any'], 'localport=8080'],
python_shell=False) python_shell=False)
def test_add_rule_icmp4(self): def test_add_rule_icmp4(self):
@ -111,8 +111,12 @@ class WinFirewallTestCase(TestCase):
mock_cmd = MagicMock(return_value='Ok.') mock_cmd = MagicMock(return_value='Ok.')
with patch.dict(win_firewall.__salt__, {'cmd.run': mock_cmd}): with patch.dict(win_firewall.__salt__, {'cmd.run': mock_cmd}):
self.assertTrue(win_firewall.add_rule("test", "1", protocol='icmpv4')) self.assertTrue(win_firewall.add_rule("test", "1", protocol='icmpv4'))
mock_cmd.assert_called_once_with(['netsh', 'advfirewall', 'firewall', 'add', 'rule', 'name=test', mock_cmd.assert_called_once_with(['netsh', 'advfirewall', 'firewall', 'add', 'rule',
'protocol=icmpv4', 'dir=in', 'action=allow'], 'name=test',
'protocol=icmpv4',
'dir=in',
'action=allow',
'remoteip=any'],
python_shell=False) python_shell=False)
def test_add_rule_icmp6(self): def test_add_rule_icmp6(self):
@ -122,8 +126,12 @@ class WinFirewallTestCase(TestCase):
mock_cmd = MagicMock(return_value='Ok.') mock_cmd = MagicMock(return_value='Ok.')
with patch.dict(win_firewall.__salt__, {'cmd.run': mock_cmd}): with patch.dict(win_firewall.__salt__, {'cmd.run': mock_cmd}):
self.assertTrue(win_firewall.add_rule("test", "1", protocol='icmpv6')) self.assertTrue(win_firewall.add_rule("test", "1", protocol='icmpv6'))
mock_cmd.assert_called_once_with(['netsh', 'advfirewall', 'firewall', 'add', 'rule', 'name=test', mock_cmd.assert_called_once_with(['netsh', 'advfirewall', 'firewall', 'add', 'rule',
'protocol=icmpv6', 'dir=in', 'action=allow'], 'name=test',
'protocol=icmpv6',
'dir=in',
'action=allow',
'remoteip=any'],
python_shell=False) python_shell=False)
def test_add_rule_icmp4_any(self): def test_add_rule_icmp4_any(self):
@ -133,8 +141,12 @@ class WinFirewallTestCase(TestCase):
mock_cmd = MagicMock(return_value='Ok.') mock_cmd = MagicMock(return_value='Ok.')
with patch.dict(win_firewall.__salt__, {'cmd.run': mock_cmd}): with patch.dict(win_firewall.__salt__, {'cmd.run': mock_cmd}):
self.assertTrue(win_firewall.add_rule("test", "1", protocol='icmpv4:any,any')) 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', mock_cmd.assert_called_once_with(['netsh', 'advfirewall', 'firewall', 'add', 'rule',
'protocol=icmpv4:any,any', 'dir=in', 'action=allow'], 'name=test',
'protocol=icmpv4:any,any',
'dir=in',
'action=allow',
'remoteip=any'],
python_shell=False) python_shell=False)
# 'delete_rule' function tests: 1 # 'delete_rule' function tests: 1
@ -151,8 +163,8 @@ class WinFirewallTestCase(TestCase):
'firewall', 'delete', 'rule', 'firewall', 'delete', 'rule',
'name=test', 'protocol=tcp', 'name=test', 'protocol=tcp',
'dir=in', 'dir=in',
'localport=8080', 'remoteip=any',
'remoteip=any'], 'localport=8080'],
python_shell=False) python_shell=False)
def test_delete_rule_icmp4(self): def test_delete_rule_icmp4(self):
@ -162,8 +174,11 @@ class WinFirewallTestCase(TestCase):
mock_cmd = MagicMock(return_value='Ok.') mock_cmd = MagicMock(return_value='Ok.')
with patch.dict(win_firewall.__salt__, {'cmd.run': mock_cmd}): with patch.dict(win_firewall.__salt__, {'cmd.run': mock_cmd}):
self.assertTrue(win_firewall.delete_rule("test", "1", protocol='icmpv4')) self.assertTrue(win_firewall.delete_rule("test", "1", protocol='icmpv4'))
mock_cmd.assert_called_once_with(['netsh', 'advfirewall', 'firewall', 'delete', 'rule', 'name=test', mock_cmd.assert_called_once_with(['netsh', 'advfirewall', 'firewall', 'delete', 'rule',
'protocol=icmpv4', 'dir=in'], 'name=test',
'protocol=icmpv4',
'dir=in',
'remoteip=any'],
python_shell=False) python_shell=False)
def test_delete_rule_icmp6(self): def test_delete_rule_icmp6(self):
@ -173,8 +188,11 @@ class WinFirewallTestCase(TestCase):
mock_cmd = MagicMock(return_value='Ok.') mock_cmd = MagicMock(return_value='Ok.')
with patch.dict(win_firewall.__salt__, {'cmd.run': mock_cmd}): with patch.dict(win_firewall.__salt__, {'cmd.run': mock_cmd}):
self.assertTrue(win_firewall.delete_rule("test", "1", protocol='icmpv6')) self.assertTrue(win_firewall.delete_rule("test", "1", protocol='icmpv6'))
mock_cmd.assert_called_once_with(['netsh', 'advfirewall', 'firewall', 'delete', 'rule', 'name=test', mock_cmd.assert_called_once_with(['netsh', 'advfirewall', 'firewall', 'delete', 'rule',
'protocol=icmpv6', 'dir=in'], 'name=test',
'protocol=icmpv6',
'dir=in',
'remoteip=any'],
python_shell=False) python_shell=False)
def test_delete_rule_icmp4_any(self): def test_delete_rule_icmp4_any(self):
@ -184,8 +202,11 @@ class WinFirewallTestCase(TestCase):
mock_cmd = MagicMock(return_value='Ok.') mock_cmd = MagicMock(return_value='Ok.')
with patch.dict(win_firewall.__salt__, {'cmd.run': mock_cmd}): with patch.dict(win_firewall.__salt__, {'cmd.run': mock_cmd}):
self.assertTrue(win_firewall.delete_rule("test", "1", protocol='icmpv4:any,any')) 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', mock_cmd.assert_called_once_with(['netsh', 'advfirewall', 'firewall', 'delete', 'rule',
'protocol=icmpv4:any,any', 'dir=in'], 'name=test',
'protocol=icmpv4:any,any',
'dir=in',
'remoteip=any'],
python_shell=False) python_shell=False)