mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Create test user and test lowercase
This commit is contained in:
parent
6756f8897c
commit
65ba161cd8
1 changed files with 14 additions and 4 deletions
|
@ -1,7 +1,9 @@
|
|||
import platform
|
||||
|
||||
import pytest
|
||||
from saltfactories.utils import random_string
|
||||
|
||||
import salt.modules.win_useradd
|
||||
import salt.utils.win_functions as win_functions
|
||||
from tests.support.mock import MagicMock, patch
|
||||
|
||||
|
@ -36,6 +38,14 @@ except ImportError:
|
|||
HAS_PYWIN = False
|
||||
|
||||
|
||||
@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)
|
||||
|
||||
|
||||
# Test cases for salt.utils.win_functions.
|
||||
|
||||
|
||||
|
@ -176,7 +186,7 @@ def test_get_sam_name_everyone():
|
|||
|
||||
|
||||
@pytest.mark.skipif(not HAS_PYWIN, reason="Requires pywintypes libraries")
|
||||
def test_get_sam_name():
|
||||
expected = "\\".join([platform.node()[:15], "Administrator"])
|
||||
result = win_functions.get_sam_name("Administrator")
|
||||
assert result == expected
|
||||
def test_get_sam_name(test_user):
|
||||
expected = "\\".join([platform.node()[:15], test_user])
|
||||
result = win_functions.get_sam_name(test_user)
|
||||
assert result.lower() == expected.lower()
|
||||
|
|
Loading…
Add table
Reference in a new issue