mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Fix some test issues, use sort
This commit is contained in:
parent
b7dd23ef4e
commit
979457d935
3 changed files with 36 additions and 19 deletions
|
@ -329,7 +329,7 @@ class daclConstants:
|
|||
return path
|
||||
|
||||
|
||||
def _getUserSid(user):
|
||||
def _get_user_sid(user):
|
||||
"""
|
||||
return a state error dictionary, with 'sid' as a field if it could be returned
|
||||
if user is None, sid will also be None
|
||||
|
@ -413,7 +413,7 @@ def get(path, objectType, user=None):
|
|||
"""
|
||||
ret = {"Path": path, "ACLs": []}
|
||||
|
||||
sidRet = _getUserSid(user)
|
||||
sidRet = _get_user_sid(user)
|
||||
|
||||
if path and objectType:
|
||||
dc = daclConstants()
|
||||
|
@ -458,7 +458,7 @@ def add_ace(path, objectType, user, permission, acetype, propagation):
|
|||
acetype = acetype.strip().upper()
|
||||
propagation = propagation.strip().upper()
|
||||
|
||||
sidRet = _getUserSid(user)
|
||||
sidRet = _get_user_sid(user)
|
||||
if not sidRet["result"]:
|
||||
return sidRet
|
||||
permissionbit = dc.getPermissionBit(objectTypeBit, permission)
|
||||
|
@ -555,7 +555,7 @@ def rm_ace(path, objectType, user, permission=None, acetype=None, propagation=No
|
|||
if check_ace(path, objectType, user, permission, acetype, propagation, True)[
|
||||
"Exists"
|
||||
]:
|
||||
sidRet = _getUserSid(user)
|
||||
sidRet = _get_user_sid(user)
|
||||
if not sidRet["result"]:
|
||||
return sidRet
|
||||
permissionbit = (
|
||||
|
@ -804,7 +804,7 @@ def check_inheritance(path, objectType, user=None):
|
|||
|
||||
ret = {"result": False, "Inheritance": False, "comment": ""}
|
||||
|
||||
sidRet = _getUserSid(user)
|
||||
sidRet = _get_user_sid(user)
|
||||
|
||||
dc = daclConstants()
|
||||
objectType = dc.getObjectTypeBit(objectType)
|
||||
|
@ -880,7 +880,7 @@ def check_ace(
|
|||
dc.getPropagationBit(objectTypeBit, propagation) if propagation else None
|
||||
)
|
||||
|
||||
sidRet = _getUserSid(user)
|
||||
sidRet = _get_user_sid(user)
|
||||
if not sidRet["result"]:
|
||||
return sidRet
|
||||
|
||||
|
|
|
@ -31,6 +31,7 @@ from datetime import datetime
|
|||
import salt.utils.args
|
||||
import salt.utils.dateutils
|
||||
import salt.utils.platform
|
||||
import salt.utils.versions
|
||||
import salt.utils.win_reg
|
||||
import salt.utils.winapi
|
||||
from salt.exceptions import CommandExecutionError
|
||||
|
@ -370,7 +371,7 @@ def delete(name, purge=False, force=False):
|
|||
# Remove the User Profile directory
|
||||
if purge:
|
||||
try:
|
||||
sid = getUserSid(name)
|
||||
sid = get_user_sid(name)
|
||||
win32profile.DeleteProfile(sid)
|
||||
except pywintypes.error as exc:
|
||||
(number, context, message) = exc.args
|
||||
|
@ -397,6 +398,23 @@ def delete(name, purge=False, force=False):
|
|||
|
||||
|
||||
def getUserSid(username):
|
||||
"""
|
||||
Deprecated function. Please use get_user_sid instead
|
||||
|
||||
CLI Example:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt '*' user.get_user_sid jsnuffy
|
||||
"""
|
||||
salt.utils.versions.warn_until(
|
||||
version=3009,
|
||||
message="'getUserSid' is being deprecated. Please use get_user_sid instead",
|
||||
)
|
||||
return get_user_sid(username)
|
||||
|
||||
|
||||
def get_user_sid(username):
|
||||
"""
|
||||
Get the Security ID for the user
|
||||
|
||||
|
@ -410,7 +428,7 @@ def getUserSid(username):
|
|||
|
||||
.. code-block:: bash
|
||||
|
||||
salt '*' user.getUserSid jsnuffy
|
||||
salt '*' user.get_user_sid jsnuffy
|
||||
"""
|
||||
domain = win32api.GetComputerName()
|
||||
if username.find("\\") != -1:
|
||||
|
|
|
@ -3,7 +3,6 @@ from saltfactories.utils import random_string
|
|||
|
||||
import salt.modules.cmdmod
|
||||
import salt.modules.win_useradd as user
|
||||
import salt.utils.data
|
||||
from salt.exceptions import CommandExecutionError
|
||||
|
||||
pytestmark = [
|
||||
|
@ -104,7 +103,7 @@ def test_chgroups_single_str(account_str):
|
|||
assert ret is True
|
||||
ret = user.info(account_str.username)
|
||||
groups.append("Users")
|
||||
assert salt.utils.data.compare_lists(ret["groups"], groups) == {}
|
||||
assert ret["groups"].sort() == groups.sort()
|
||||
|
||||
|
||||
def test_chgroups_single_int(account_int):
|
||||
|
@ -113,7 +112,7 @@ def test_chgroups_single_int(account_int):
|
|||
assert ret is True
|
||||
ret = user.info(account_int.username)
|
||||
groups.append("Users")
|
||||
assert salt.utils.data.compare_lists(ret["groups"], groups) == {}
|
||||
assert ret["groups"].sort() == groups.sort()
|
||||
|
||||
|
||||
def test_chgroups_list_str(account_str):
|
||||
|
@ -122,7 +121,7 @@ def test_chgroups_list_str(account_str):
|
|||
assert ret is True
|
||||
ret = user.info(account_str.username)
|
||||
groups.append("Users")
|
||||
assert salt.utils.data.compare_lists(ret["groups"], groups) == {}
|
||||
assert ret["groups"].sort() == groups.sort()
|
||||
|
||||
|
||||
def test_chgroups_list_int(account_int):
|
||||
|
@ -131,7 +130,7 @@ def test_chgroups_list_int(account_int):
|
|||
assert ret is True
|
||||
ret = user.info(account_int.username)
|
||||
groups.append("Users")
|
||||
assert salt.utils.data.compare_lists(ret["groups"], groups) == {}
|
||||
assert ret["groups"].sort() == groups.sort()
|
||||
|
||||
|
||||
def test_chgroups_list_append_false_str(account_str):
|
||||
|
@ -139,7 +138,7 @@ def test_chgroups_list_append_false_str(account_str):
|
|||
ret = user.chgroups(account_str.username, groups=groups, append=False)
|
||||
assert ret is True
|
||||
ret = user.info(account_str.username)
|
||||
assert salt.utils.data.compare_lists(ret["groups"], groups) == {}
|
||||
assert ret["groups"].sort() == groups.sort()
|
||||
|
||||
|
||||
def test_chgroups_list_append_false_int(account_int):
|
||||
|
@ -147,7 +146,7 @@ def test_chgroups_list_append_false_int(account_int):
|
|||
ret = user.chgroups(account_int.username, groups=groups, append=False)
|
||||
assert ret is True
|
||||
ret = user.info(account_int.username)
|
||||
assert salt.utils.data.compare_lists(ret["groups"], groups) == {}
|
||||
assert ret["groups"].sort() == groups.sort()
|
||||
|
||||
|
||||
def test_chhome_str(account_str):
|
||||
|
@ -194,13 +193,13 @@ def test_delete_int(account_int):
|
|||
assert user.info(name=account_int.username) == {}
|
||||
|
||||
|
||||
def test_getUserSig_str(account_str):
|
||||
ret = user.getUserSid(account_str.username)
|
||||
def test_get_user_sid_str(account_str):
|
||||
ret = user.get_user_sid(account_str.username)
|
||||
assert ret.startswith("S-1-5")
|
||||
|
||||
|
||||
def test_getUserSig_int(account_int):
|
||||
ret = user.getUserSid(account_int.username)
|
||||
def test_get_user_sid_int(account_int):
|
||||
ret = user.get_user_sid(account_int.username)
|
||||
assert ret.startswith("S-1-5")
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue