Debian Codegraph @

test/units/plugins/shell/test_cmd.py

raw
1 from __future__ import annotations
2
3 import pytest
4
5 from ansible.plugins.shell.cmd import ShellModule
6
7
8 @pytest.mark.parametrize('s, expected', [
9 ['arg1', 'arg1'],
10 [None, '""'],
11 ['arg1 and 2', '^"arg1 and 2^"'],
12 ['malicious argument\\"&whoami', '^"malicious argument\\\\^"^&whoami^"'],
13 ['C:\\temp\\some ^%file% > nul', '^"C:\\temp\\some ^^^%file^% ^> nul^"']
14 ])
15 def test_quote_args(s, expected):
16 cmd = ShellModule()
17 actual = cmd.quote(s)
18 assert actual == expected