mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Add test user to check
This commit is contained in:
parent
69c11b5f5c
commit
b7385b0e28
1 changed files with 13 additions and 3 deletions
|
@ -2,8 +2,10 @@ import os
|
|||
import re
|
||||
|
||||
import pytest
|
||||
from saltfactories.utils import random_string
|
||||
|
||||
import salt.modules.win_file as win_file
|
||||
import salt.modules.win_useradd as win_useradd
|
||||
import salt.utils.user
|
||||
import salt.utils.win_dacl
|
||||
from salt.exceptions import CommandExecutionError
|
||||
|
@ -20,6 +22,14 @@ def configure_loader_modules():
|
|||
}
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def test_user():
|
||||
user_name = random_string("test-")
|
||||
salt.modules.win_useradd.add(name=user_name, password="P@ssw0rd")
|
||||
yield user_name
|
||||
salt.modules.win_useradd.delete(name=user_name)
|
||||
|
||||
|
||||
def test__virtual__not_windows():
|
||||
with patch("salt.utils.platform.is_windows", autospec=True, return_value=False):
|
||||
expected = (False, "Module win_file: Missing Win32 modules")
|
||||
|
@ -126,9 +136,9 @@ def test_uid_to_user_empty():
|
|||
assert result == expected
|
||||
|
||||
|
||||
def test_user_to_uid():
|
||||
result = win_file.user_to_uid("Administrator")
|
||||
expected = salt.utils.win_dacl.get_sid_string("Administrator")
|
||||
def test_user_to_uid(test_user):
|
||||
result = win_file.user_to_uid(test_user)
|
||||
expected = salt.utils.win_dacl.get_sid_string(test_user)
|
||||
assert result == expected
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue