Ejemplo n.º 1
0
    def test_disable(self):
        """
        Test if it disable an interface.
        """
        with patch.object(win_ip, "is_disabled", return_value=True):
            self.assertTrue(win_ip.disable("Ethernet"))

        mock_cmd = MagicMock()
        with patch.object(win_ip, "is_disabled",
                          side_effect=[False, True
                                       ]), patch.dict(win_ip.__salt__,
                                                      {"cmd.run": mock_cmd}):
            self.assertTrue(win_ip.disable("Ethernet"))

        mock_cmd.called_once_with(
            [
                "netsh",
                "interface",
                "set",
                "interface",
                "name=Ethernet",
                "admin=DISABLED",
            ],
            python_shell=False,
        )
Ejemplo n.º 2
0
    def test_disable(self):
        '''
        Test if it disable an interface.
        '''
        with patch.object(win_ip, 'is_disabled', return_value=True):
            self.assertTrue(win_ip.disable('Ethernet'))

        mock_cmd = MagicMock()
        with patch.object(win_ip, 'is_disabled', side_effect=[False, True]),\
                patch.dict(win_ip.__salt__, {'cmd.run': mock_cmd}):
            self.assertTrue(win_ip.disable('Ethernet'))

        mock_cmd.called_once_with([
            'netsh', 'interface', 'set', 'interface', 'name=Ethernet',
            'admin=DISABLED'
        ],
                                  python_shell=False)
Ejemplo n.º 3
0
    def test_verify_password_invalid_account_gets_locked(self):
        '''
        Test verify_password with an invalid password that locks the account
        '''
        mock_info = MagicMock(side_effect=[{
            'account_locked': False
        }, {
            'account_locked': True
        }])
        mock_update = MagicMock(return_value=True)

        win_error = WinError()
        win_error.winerror = winerror.ERROR_LOGON_FAILURE

        mock_logon_user = MagicMock(side_effect=win_error)

        with patch.dict(win_shadow.__salt__, {'user.info': mock_info}), \
                patch.dict(win_shadow.__salt__, {'user.update': mock_update}), \
                patch('salt.modules.win_shadow.win32security.LogonUser',
                      mock_logon_user):
            ret = win_shadow.verify_password(name='spongebob',
                                             password='******')
            mock_update.called_once_with('spongebob', unlock_account=True)
            self.assertFalse(ret)