2020-06-22 22:27:08 +02:00
|
|
|
from __future__ import (absolute_import, division, print_function)
|
|
|
|
__metaclass__ = type
|
|
|
|
|
2019-03-08 01:38:02 +01:00
|
|
|
import pytest
|
|
|
|
|
|
|
|
from ansible.plugins.shell.cmd import ShellModule
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.parametrize('s, expected', [
|
|
|
|
['arg1', 'arg1'],
|
|
|
|
[None, '""'],
|
|
|
|
['arg1 and 2', '^"arg1 and 2^"'],
|
2020-04-16 12:24:23 +02:00
|
|
|
['malicious argument\\"&whoami', '^"malicious argument\\\\^"^&whoami^"'],
|
2019-03-08 01:38:02 +01:00
|
|
|
['C:\\temp\\some ^%file% > nul', '^"C:\\temp\\some ^^^%file^% ^> nul^"']
|
|
|
|
])
|
|
|
|
def test_quote_args(s, expected):
|
|
|
|
cmd = ShellModule()
|
|
|
|
actual = cmd.quote(s)
|
|
|
|
assert actual == expected
|