def test_get_user_groups_local_pywin_error():
    win_error = PyWinError()
    win_error.winerror = 1355
    mock_error = MagicMock(side_effect=win_error)
    with patch("win32net.NetUserGetLocalGroups", side_effect=mock_error):
        with pytest.raises(PyWinError):
            win_functions.get_user_groups("Administrator")
Exemple #2
0
 def test_get_user_groups_error(self):
     win_error = WinError()
     win_error.winerror = 1927
     mock_error = MagicMock(side_effect=win_error)
     with patch('win32net.NetUserGetLocalGroups', side_effect=mock_error):
         with self.assertRaises(WinError):
             win_functions.get_user_groups('Administrator')
def test_get_user_groups_missing_permission():
    groups = ["Administrators", "Users"]
    win_error = WinError()
    win_error.winerror = 5
    effect = [win_error, groups]
    with patch("win32net.NetUserGetLocalGroups", side_effect=effect):
        assert win_functions.get_user_groups("Administrator") == groups
def test_get_user_groups_unavailable_dc():
    groups = ["Administrators", "Users"]
    win_error = WinError()
    win_error.winerror = 1722
    effect = [win_error, groups]
    with patch("win32net.NetUserGetLocalGroups", side_effect=effect):
        assert win_functions.get_user_groups("Administrator") == groups
Exemple #5
0
 def test_get_user_groups_unavailable_dc(self):
     groups = ['Administrators', 'Users']
     win_error = WinError()
     win_error.winerror = 1722
     effect = [win_error, groups]
     with patch('win32net.NetUserGetLocalGroups', side_effect=effect):
         ret = win_functions.get_user_groups('Administrator')
         self.assertListEqual(groups, ret)
Exemple #6
0
 def test_get_user_groups_unknown_dc(self):
     groups = ["Administrators", "Users"]
     win_error = WinError()
     win_error.winerror = 2453
     effect = [win_error, groups]
     with patch("win32net.NetUserGetLocalGroups", side_effect=effect):
         ret = win_functions.get_user_groups("Administrator")
         self.assertListEqual(groups, ret)
Exemple #7
0
 def test_get_user_groups_system(self):
     groups = ['SYSTEM']
     with patch('win32net.NetUserGetLocalGroups', return_value=groups):
         ret = win_functions.get_user_groups('SYSTEM')
         self.assertListEqual(groups, ret)
Exemple #8
0
 def test_get_user_groups_sid(self):
     groups = ['Administrators', 'Users']
     expected = ['S-1-5-32-544', 'S-1-5-32-545']
     with patch('win32net.NetUserGetLocalGroups', return_value=groups):
         ret = win_functions.get_user_groups('Administrator', sid=True)
         self.assertListEqual(expected, ret)
Exemple #9
0
 def test_get_user_groups(self):
     groups = ['Administrators', 'Users']
     with patch('win32net.NetUserGetLocalGroups', return_value=groups):
         ret = win_functions.get_user_groups('Administrator')
         self.assertListEqual(groups, ret)
Exemple #10
0
 def test_get_user_groups_sid(self):
     groups = ["Administrators", "Users"]
     expected = ["S-1-5-32-544", "S-1-5-32-545"]
     with patch("win32net.NetUserGetLocalGroups", return_value=groups):
         ret = win_functions.get_user_groups("Administrator", sid=True)
         self.assertListEqual(expected, ret)
Exemple #11
0
 def test_get_user_groups(self):
     groups = ["Administrators", "Users"]
     with patch("win32net.NetUserGetLocalGroups", return_value=groups):
         ret = win_functions.get_user_groups("Administrator")
         self.assertListEqual(groups, ret)
def test_get_user_groups():
    groups = ["Administrators", "Users"]
    with patch("win32net.NetUserGetLocalGroups", return_value=groups):
        assert win_functions.get_user_groups("Administrator") == groups
def test_get_user_groups_system():
    groups = ["SYSTEM"]
    with patch("win32net.NetUserGetLocalGroups", return_value=groups):
        assert win_functions.get_user_groups("SYSTEM") == groups