Example #1
0
 def test__set_netsh_value_logging(self):
     '''
     Test setting firewall logging
     '''
     context = {
         'lgpo.netsh_data': {
             'private': {
                 'allowedconnections': 'notconfigured'
             }
         }
     }
     expected = {
         'lgpo.netsh_data': {
             'private': {
                 'allowedconnections': 'enable'
             }
         }
     }
     with patch('salt.utils.win_lgpo_netsh.set_logging_settings',
                MagicMock(return_value=True)), \
             patch.dict(win_lgpo.__context__, context):
         result = win_lgpo._set_netsh_value(profile='private',
                                            section='logging',
                                            option='allowedconnections',
                                            value='enable')
         self.assertTrue(result)
         self.assertEqual(win_lgpo.__context__, expected)
Example #2
0
 def test__set_netsh_value_settings(self):
     '''
     Test setting firewall settings
     '''
     context = {
         'lgpo.netsh_data': {
             'private': {
                 'localfirewallrules': 'disable'
             }
         }
     }
     expected = {
         'lgpo.netsh_data': {
             'private': {
                 'localfirewallrules': 'enable'
             }
         }
     }
     with patch('salt.utils.win_lgpo_netsh.set_settings',
                MagicMock(return_value=True)), \
             patch.dict(win_lgpo.__context__, context):
         result = win_lgpo._set_netsh_value(profile='private',
                                            section='settings',
                                            option='localfirewallrules',
                                            value='enable')
         self.assertTrue(result)
         self.assertEqual(win_lgpo.__context__, expected)
Example #3
0
 def test__set_netsh_value_state(self):
     '''
     Test setting the firewall state
     '''
     context = {'lgpo.netsh_data': {'private': {'State': 'notconfigured'}}}
     expected = {'lgpo.netsh_data': {'private': {'State': 'on'}}}
     with patch('salt.utils.win_lgpo_netsh.set_state',
                MagicMock(return_value=True)), \
             patch.dict(win_lgpo.__context__, context):
         result = win_lgpo._set_netsh_value(profile='private',
                                            section='state',
                                            option='unused',
                                            value='on')
         self.assertTrue(result)
         self.assertEqual(win_lgpo.__context__, expected)
Example #4
0
 def test__set_netsh_value_firewall(self):
     '''
     Test setting the firewall inbound policy
     '''
     context = {'lgpo.netsh_data': {'Private': {'Inbound': 'Block'}}}
     expected = {'lgpo.netsh_data': {'Private': {'Inbound': 'Allow'}}}
     with patch('salt.utils.win_lgpo_netsh.set_firewall_settings',
                MagicMock(return_value=True)),\
             patch.dict(win_lgpo.__context__, context):
         result = win_lgpo._set_netsh_value(profile='Private',
                                            section='firewallpolicy',
                                            option='Inbound',
                                            value='Allow')
         self.assertTrue(result)
         self.assertEqual(win_lgpo.__context__, expected)