mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Use actual shell in test
This commit is contained in:
parent
2b45cd6ee5
commit
02e110abc7
2 changed files with 22 additions and 12 deletions
|
@ -2939,21 +2939,29 @@ def script(
|
|||
os.chown(path, __salt__["file.user_to_uid"](runas), -1)
|
||||
|
||||
if salt.utils.platform.is_windows():
|
||||
if shell.lower() != "powershell":
|
||||
if shell.lower() not in ["powershell", "pwsh"]:
|
||||
cmd_path = _cmd_quote(path, escape=False)
|
||||
else:
|
||||
cmd_path = path
|
||||
if not env:
|
||||
env = {}
|
||||
mod_paths = [
|
||||
pathlib.Path(
|
||||
rf'{os.getenv("SystemRoot")}\System32\WindowsPowerShell\v1.0\Modules'
|
||||
),
|
||||
pathlib.Path(rf'{os.getenv("ProgramFiles")}\WindowsPowerShell\Modules'),
|
||||
pathlib.Path(
|
||||
rf'{os.getenv("ProgramFiles(x86)", "")}\WindowsPowerShell\Modules'
|
||||
),
|
||||
]
|
||||
if shell.lower() == "powershell":
|
||||
mod_paths = [
|
||||
pathlib.Path(
|
||||
rf'{os.getenv("SystemRoot")}\System32\WindowsPowerShell\v1.0\Modules'
|
||||
),
|
||||
pathlib.Path(
|
||||
rf'{os.getenv("ProgramFiles")}\WindowsPowerShell\Modules'
|
||||
),
|
||||
]
|
||||
else:
|
||||
mod_paths = [
|
||||
pathlib.Path(rf'{os.getenv("ProgramFiles")}\PowerShell\Modules'),
|
||||
pathlib.Path(
|
||||
rf'{os.getenv("ProgramFiles")}\PowerShell\6.0.0\Modules'
|
||||
),
|
||||
pathlib.Path(rf'{os.getenv("ProgramFiles")}\PowerShell\7\Modules'),
|
||||
]
|
||||
ps_module_path = [
|
||||
pathlib.Path(x) for x in os.getenv("PSModulePath", "").split(";")
|
||||
]
|
||||
|
|
|
@ -57,7 +57,9 @@ def test_windows_script_args_powershell(cmd, shell, issue_56195):
|
|||
)
|
||||
script = "salt://issue-56195/test.ps1"
|
||||
|
||||
ret = cmd.script(source=script, args=args, shell="powershell", saltenv="base")
|
||||
ret = cmd.script(source=script, args=args, shell=shell, saltenv="base")
|
||||
|
||||
import_result = cmd.run("Import-Module Microsoft.PowerShell.Security", shell=shell)
|
||||
|
||||
assert ret["stdout"] == password
|
||||
|
||||
|
@ -78,7 +80,7 @@ def test_windows_script_args_powershell_runas(cmd, shell, account, issue_56195):
|
|||
ret = cmd.script(
|
||||
source=script,
|
||||
args=args,
|
||||
shell="powershell",
|
||||
shell=shell,
|
||||
saltenv="base",
|
||||
runas=account.username,
|
||||
password=account.password,
|
||||
|
|
Loading…
Add table
Reference in a new issue