Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added depth parameter to win_uri ConvertTo-Json call #587

Merged
merged 7 commits into from
Mar 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions changelogs/fragments/PR-587-Fix-win_uri-json-depth.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
minor_changes:
- win_uri - Max depth for json object conversion used to be 2. Can now send json objects with up to 20 levels of nesting
2 changes: 1 addition & 1 deletion plugins/modules/win_uri.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ $response_script = {
$body_st = $null
if ($null -ne $body) {
if ($body -is [System.Collections.IDictionary] -or $body -is [System.Collections.IList]) {
$body_string = ConvertTo-Json -InputObject $body -Compress
$body_string = ConvertTo-Json -InputObject $body -Compress -Depth 20
thomasriera-akkodis marked this conversation as resolved.
Show resolved Hide resolved
}
elseif ($body -isnot [String]) {
$body_string = $body.ToString()
Expand Down
46 changes: 46 additions & 0 deletions tests/integration/targets/win_uri/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,52 @@
- not json_as_dict.changed
- json_as_dict.json.json == json_as_dict_value
- json_as_dict.status_code == 200

- name: send JSON body with multiple levels of nesting
win_uri:
url: https://{{httpbin_host}}/post
method: POST
body:
foo: bar
list:
- 1
- 2
dict:
foo: bar
dict:
foo: bar
dict:
foo: bar
dict:
foo: bar
headers:
'Content-Type': 'text/json'
return_content: yes
register: nested_json_as_dict

- name: set fact of expected json dict
set_fact:
nested_json_as_dict_value:
foo: bar
list:
- 1
- 2
dict:
foo: bar
dict:
foo: bar
dict:
foo: bar
dict:
foo: bar

- name: assert send JSON body with multiple levels of nesting
assert:
that:
- not nested_json_as_dict.changed
- nested_json_as_dict.json.json == nested_json_as_dict_value
- nested_json_as_dict.status_code == 200


- name: send JSON body with 1 item in list
win_uri:
Expand Down