mirror of
https://github.com/saltstack/salt.git
synced 2025-04-16 09:40:20 +00:00
use whoami in the tests
This commit is contained in:
parent
61890f79af
commit
af906c795e
2 changed files with 8 additions and 7 deletions
|
@ -187,7 +187,7 @@ class HANDLE(wintypes.HANDLE):
|
||||||
if self and not getattr(self, "closed", False):
|
if self and not getattr(self, "closed", False):
|
||||||
try:
|
try:
|
||||||
CloseHandle(self.Detach())
|
CloseHandle(self.Detach())
|
||||||
except Exception:
|
except OSError:
|
||||||
# Suppress the error when there is no handle (WinError 6)
|
# Suppress the error when there is no handle (WinError 6)
|
||||||
if ctypes.get_last_error() == 6:
|
if ctypes.get_last_error() == 6:
|
||||||
pass
|
pass
|
||||||
|
|
|
@ -18,21 +18,22 @@ def user():
|
||||||
yield account
|
yield account
|
||||||
|
|
||||||
|
|
||||||
def test_runas(user):
|
def test_compound_runas(user):
|
||||||
cmd = "hostname && echo foo"
|
cmd = "hostname && whoami"
|
||||||
result = win_runas.runas(
|
result = win_runas.runas(
|
||||||
cmdLine=cmd,
|
cmdLine=cmd,
|
||||||
username=user.username,
|
username=user.username,
|
||||||
password=user.password,
|
password=user.password,
|
||||||
)
|
)
|
||||||
assert "foo" in result["stdout"]
|
assert user.username in result["stdout"]
|
||||||
|
|
||||||
|
|
||||||
def test_runas_unpriv(user):
|
def test_compound_runas_unpriv(user):
|
||||||
cmd = "hostname && echo foo"
|
cmd = "hostname && whoami"
|
||||||
|
print(user.username)
|
||||||
result = win_runas.runas_unpriv(
|
result = win_runas.runas_unpriv(
|
||||||
cmd=cmd,
|
cmd=cmd,
|
||||||
username=user.username,
|
username=user.username,
|
||||||
password=user.password,
|
password=user.password,
|
||||||
)
|
)
|
||||||
assert "foo" in result["stdout"]
|
assert user.username in result["stdout"]
|
||||||
|
|
Loading…
Add table
Reference in a new issue