From a0178b79f100a110072dceaa57f71033d7327855 Mon Sep 17 00:00:00 2001 From: Jordan Borean Date: Wed, 7 Feb 2018 20:58:47 +1100 Subject: [PATCH] win_uri: fixes (#35487) * win_uri: moved away from Invoke-WebRequest and fixed multiple issues * fixes from review --- .../Ansible.ModuleUtils.Legacy.psm1 | 2 + lib/ansible/modules/windows/win_uri.ps1 | 237 ++++++++++---- lib/ansible/modules/windows/win_uri.py | 70 ++-- .../targets/uri/files/testserver.ps1 | 36 --- test/integration/targets/win_uri/aliases | 1 + .../targets/win_uri/defaults/main.yml | 3 + .../targets/win_uri/tasks/main.yml | 14 + .../targets/win_uri/tasks/test.yml | 298 ++++++++++++++++++ test/sanity/pslint/ignore.txt | 1 - 9 files changed, 528 insertions(+), 134 deletions(-) delete mode 100644 test/integration/targets/uri/files/testserver.ps1 create mode 100644 test/integration/targets/win_uri/aliases create mode 100644 test/integration/targets/win_uri/defaults/main.yml create mode 100644 test/integration/targets/win_uri/tasks/main.yml create mode 100644 test/integration/targets/win_uri/tasks/test.yml diff --git a/lib/ansible/module_utils/powershell/Ansible.ModuleUtils.Legacy.psm1 b/lib/ansible/module_utils/powershell/Ansible.ModuleUtils.Legacy.psm1 index a5e7a7c70b..9dad05728e 100644 --- a/lib/ansible/module_utils/powershell/Ansible.ModuleUtils.Legacy.psm1 +++ b/lib/ansible/module_utils/powershell/Ansible.ModuleUtils.Legacy.psm1 @@ -214,6 +214,8 @@ Function Get-AnsibleParam($obj, $name, $default = $null, $resultobj = @{}, $fail } elseif ($value -is [string]) { # Convert string type to real Powershell array $value = $value.Split(",").Trim() + } elseif ($value -is [int]) { + $value = @($value) } else { Fail-Json -obj $resultobj -message "Get-AnsibleParam: Parameter '$name' is not a YAML list." } diff --git a/lib/ansible/modules/windows/win_uri.ps1 b/lib/ansible/modules/windows/win_uri.ps1 index 5e7ec6b3b6..6ace1c3cd7 100644 --- a/lib/ansible/modules/windows/win_uri.ps1 +++ b/lib/ansible/modules/windows/win_uri.ps1 @@ -5,141 +5,252 @@ # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) #Requires -Module Ansible.ModuleUtils.Legacy +#Requires -Module Ansible.ModuleUtils.CamelConversion +#Requires -Module Ansible.ModuleUtils.FileUtil $ErrorActionPreference = "Stop" -$safe_methods = @("GET", "HEAD") -$content_keys = @("Content", "Images", "InputFields", "Links", "RawContent") - -Function ConvertTo-SnakeCase($input_string) { - $snake_case = $input_string -csplit "(?