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

win_uri: fix creates/removes option #36016

Merged
merged 1 commit into from
Feb 14, 2018
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 5 additions & 5 deletions lib/ansible/modules/windows/win_uri.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ $validate_certs = Get-AnsibleParam -obj $params -name "validate_certs" -type "bo
$client_cert = Get-AnsibleParam -obj $params -name "client_cert" -type "path"
$client_cert_password = Get-AnsibleParam -obj $params -name "client_cert_password" -type "str"

$result = @{
changed = $false
url = $url
}

if ($creates -and (Test-AnsiblePath -Path $creates)) {
$result.skipped = $true
Exit-Json -obj $result -message "The 'creates' file or directory ($creates) already exists."
Expand All @@ -47,11 +52,6 @@ if ($removes -and -not (Test-AnsiblePath -Path $removes)) {
Exit-Json -obj $result -message "The 'removes' file or directory ($removes) does not exist."
}

$result = @{
changed = $false
url = $url
}

if ($use_basic_parsing) {
Add-DeprecationWarning -obj $result -message "Since Ansible 2.5, use_basic_parsing does not change any behaviour, this option will be removed" -version 2.7
}
Expand Down
24 changes: 24 additions & 0 deletions test/integration/targets/win_uri/tasks/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,30 @@
that:
- not get_request_with_dest_again.changed

- name: test request with creates option should skip
win_uri:
url: http://{{httpbin_host}}/get
creates: '{{test_uri_path}}\get.json'
register: request_with_creates_skipped

- name: assert test request with creates option should skip
assert:
that:
- not request_with_creates_skipped.changed
- request_with_creates_skipped.skipped

- name: test request with creates option should not skip
win_uri:
url: http://{{httpbin_host}}/get
creates: '{{test_uri_path}}\fake.json'
register: request_with_creates_not_skipped

- name: assert test request with creates option should not skip
assert:
that:
- not request_with_creates_not_skipped.changed
- request_with_creates_not_skipped.skipped is not defined

- name: post request with return_content, dest and different content
win_uri:
url: http://{{httpbin_host}}/post
Expand Down