salt/tests/pytests/functional/utils/test_win_runas.py

38 lines
729 B
Python

"""
Test the win_runas util
"""
import pytest
import salt.utils.win_runas as win_runas
pytestmark = [
pytest.mark.windows_whitelisted,
pytest.mark.skip_unless_on_windows,
]
@pytest.fixture
def user():
with pytest.helpers.create_account() as account:
yield account
def test_runas(user):
cmd = "hostname && echo foo"
result = win_runas.runas(
cmdLine=cmd,
username=user.username,
password=user.password,
)
assert "foo" in result["stdout"]
def test_runas_unpriv(user):
cmd = "hostname && echo foo"
result = win_runas.runas_unpriv(
cmd=cmd,
username=user.username,
password=user.password,
)
assert "foo" in result["stdout"]