diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-14 20:03:01 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-14 20:03:01 +0000 |
commit | a453ac31f3428614cceb99027f8efbdb9258a40b (patch) | |
tree | f61f87408f32a8511cbd91799f9cececb53e0374 /test/units/plugins/shell/test_cmd.py | |
parent | Initial commit. (diff) | |
download | ansible-upstream.tar.xz ansible-upstream.zip |
Adding upstream version 2.10.7+merged+base+2.10.8+dfsg.upstream/2.10.7+merged+base+2.10.8+dfsgupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'test/units/plugins/shell/test_cmd.py')
-rw-r--r-- | test/units/plugins/shell/test_cmd.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/test/units/plugins/shell/test_cmd.py b/test/units/plugins/shell/test_cmd.py new file mode 100644 index 00000000..4c1a654b --- /dev/null +++ b/test/units/plugins/shell/test_cmd.py @@ -0,0 +1,19 @@ +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +import pytest + +from ansible.plugins.shell.cmd import ShellModule + + +@pytest.mark.parametrize('s, expected', [ + ['arg1', 'arg1'], + [None, '""'], + ['arg1 and 2', '^"arg1 and 2^"'], + ['malicious argument\\"&whoami', '^"malicious argument\\\\^"^&whoami^"'], + ['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 |