mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
fix 62624 by updating arg to work with str or lists.
This commit is contained in:
parent
52b9a29ea3
commit
20f4c636db
3 changed files with 41 additions and 7 deletions
1
changelog/62624.fixed
Normal file
1
changelog/62624.fixed
Normal file
|
@ -0,0 +1 @@
|
|||
updated rest_cherry/app to properly detect arg sent as a string as curl will do when only one arg is supplied.
|
|
@ -985,8 +985,13 @@ def urlencoded_processor(entity):
|
|||
unserialized_data["kwarg"]
|
||||
)
|
||||
if "arg" in unserialized_data:
|
||||
for idx, value in enumerate(unserialized_data["arg"]):
|
||||
unserialized_data["arg"][idx] = salt.utils.args.yamlify_arg(value)
|
||||
if isinstance(unserialized_data["arg"], list):
|
||||
for idx, value in enumerate(unserialized_data["arg"]):
|
||||
unserialized_data["arg"][idx] = salt.utils.args.yamlify_arg(value)
|
||||
else:
|
||||
unserialized_data["arg"] = [
|
||||
salt.utils.args.yamlify_arg(unserialized_data["arg"])
|
||||
]
|
||||
cherrypy.serving.request.unserialized_data = unserialized_data
|
||||
|
||||
|
||||
|
|
|
@ -26,18 +26,24 @@ async def test_accepts_arg_kwarg_keys(
|
|||
)
|
||||
assert response.code == 200
|
||||
token = response.headers["X-Auth-Token"]
|
||||
low = {
|
||||
low1 = {
|
||||
"client": "runner",
|
||||
"fun": "test.arg",
|
||||
"arg": [1234, 5678],
|
||||
"kwarg": {"ext_source": "redis"},
|
||||
}
|
||||
low2 = {
|
||||
"client": "runner",
|
||||
"fun": "test.arg",
|
||||
"arg": 1234,
|
||||
"kwarg": {"ext_source": "redis"},
|
||||
}
|
||||
for content_type in ("json", "form"):
|
||||
with subtests.test(content_type=content_type):
|
||||
if content_type == "json":
|
||||
body = salt.utils.json.dumps(low)
|
||||
body = salt.utils.json.dumps(low1)
|
||||
else:
|
||||
_low = low.copy()
|
||||
_low = low1.copy()
|
||||
arg = _low.pop("arg")
|
||||
body = urllib.parse.urlencode(_low)
|
||||
for _arg in arg:
|
||||
|
@ -55,5 +61,27 @@ async def test_accepts_arg_kwarg_keys(
|
|||
assert response.code == 200
|
||||
body = salt.utils.json.loads(response.body)
|
||||
ret = body["return"][0]
|
||||
assert ret["args"] == low["arg"]
|
||||
assert ret["kwargs"] == low["kwarg"]
|
||||
assert ret["args"] == low1["arg"]
|
||||
assert ret["kwargs"] == low1["kwarg"]
|
||||
if content_type == "json":
|
||||
body = salt.utils.json.dumps(low2)
|
||||
else:
|
||||
_low = low2.copy()
|
||||
arg = _low.pop("arg")
|
||||
body = urllib.parse.urlencode(_low)
|
||||
body += "&arg={}".format(arg)
|
||||
response = await http_client.fetch(
|
||||
"/",
|
||||
method="POST",
|
||||
body=body,
|
||||
headers={
|
||||
"Accept": content_type_map["json"],
|
||||
"Content-Type": content_type_map[content_type],
|
||||
"X-Auth-Token": token,
|
||||
},
|
||||
)
|
||||
assert response.code == 200
|
||||
body = salt.utils.json.loads(response.body)
|
||||
ret = body["return"][0]
|
||||
assert ret["args"][0] == low2["arg"]
|
||||
assert ret["kwargs"] == low1["kwarg"]
|
||||
|
|
Loading…
Add table
Reference in a new issue