mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Skip tests when we can not use runas
This commit is contained in:
parent
82fb6ba366
commit
a48ac26573
1 changed files with 23 additions and 0 deletions
|
@ -37,6 +37,7 @@ from tests.support.case import ModuleCase
|
|||
import salt.utils
|
||||
import salt.utils.win_dacl
|
||||
import salt.utils.win_functions
|
||||
import salt.utils.win_runas
|
||||
from salt.modules.virtualenv_mod import KNOWN_BINARY_NAMES
|
||||
from salt.exceptions import CommandExecutionError
|
||||
|
||||
|
@ -44,6 +45,26 @@ from salt.exceptions import CommandExecutionError
|
|||
import salt.ext.six as six
|
||||
|
||||
|
||||
def can_runas():
|
||||
'''
|
||||
Detect if we are running in a limited shell (winrm) and are un-able to use
|
||||
the runas
|
||||
'''
|
||||
if salt.utils.is_windows():
|
||||
try:
|
||||
salt.utils.win_runas.run_as(
|
||||
'cmd.exe /c echo 1', 'noexistuser', 'n0existp4ss',
|
||||
)
|
||||
except WindowsError as exc:
|
||||
if exc.winerror == 5:
|
||||
# Access Denied
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
CAN_RUNAS = can_runas()
|
||||
|
||||
|
||||
class VirtualEnv(object):
|
||||
def __init__(self, test, venv_dir):
|
||||
self.venv_dir = venv_dir
|
||||
|
@ -270,6 +291,7 @@ class PipStateTest(ModuleCase, SaltReturnAssertsMixin):
|
|||
|
||||
@destructiveTest
|
||||
@skip_if_not_root
|
||||
@skipIf(not CAN_RUNAS, 'Runas support required')
|
||||
@with_system_user('issue-6912', on_existing='delete', delete=True,
|
||||
password='PassWord1!')
|
||||
@with_tempdir()
|
||||
|
@ -313,6 +335,7 @@ class PipStateTest(ModuleCase, SaltReturnAssertsMixin):
|
|||
|
||||
@destructiveTest
|
||||
@skip_if_not_root
|
||||
@skipIf(not CAN_RUNAS, 'Runas support required')
|
||||
@with_system_user('issue-6912', on_existing='delete', delete=True,
|
||||
password='PassWord1!')
|
||||
@with_tempdir()
|
||||
|
|
Loading…
Add table
Reference in a new issue