mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-06 13:22:48 +00:00
uri: check unexpected failure doesn't occur when file cannot be saved (#45824)
* uri: fix TypeError when file can't be saved
Fix the following exception (and others):
Traceback (most recent call last):
File "/home/lilou/debug_dir/__main__.py", line 604, in <module>
main()
File "/home/lilou/debug_dir/__main__.py", line 554, in main
write_file(module, url, dest, content, resp)
File "/home/lilou/debug_dir/__main__.py", line 320, in write_file
module.fail_json(msg="Destination dir '%s' not writable" % os.path.dirname(dest), **resp)
TypeError: fail_json() got multiple values for keyword argument 'msg'
I would rather remove **resp from returned values but this module is
flagged as stableinterface.
* Static imports are more straight forward and preferred unless dynamic inclusion is required.
This commit is contained in:
@@ -488,13 +488,16 @@
|
||||
- result.json.json[0] == 'JSON Test Pattern pass1'
|
||||
|
||||
- name: Test follow_redirects=none
|
||||
include_tasks: redirect-none.yml
|
||||
import_tasks: redirect-none.yml
|
||||
|
||||
- name: Test follow_redirects=safe
|
||||
include_tasks: redirect-safe.yml
|
||||
import_tasks: redirect-safe.yml
|
||||
|
||||
- name: Test follow_redirects=urllib2
|
||||
include_tasks: redirect-urllib2.yml
|
||||
import_tasks: redirect-urllib2.yml
|
||||
|
||||
- name: Test follow_redirects=all
|
||||
include_tasks: redirect-all.yml
|
||||
import_tasks: redirect-all.yml
|
||||
|
||||
- name: Check unexpected failures
|
||||
import_tasks: unexpected-failures.yml
|
||||
|
||||
27
test/integration/targets/uri/tasks/unexpected-failures.yml
Normal file
27
test/integration/targets/uri/tasks/unexpected-failures.yml
Normal file
@@ -0,0 +1,27 @@
|
||||
---
|
||||
# same as expanduser & expandvars called on managed host
|
||||
- command: 'echo {{ output_dir }}'
|
||||
register: echo
|
||||
|
||||
- set_fact:
|
||||
remote_dir_expanded: '{{ echo.stdout }}'
|
||||
|
||||
- name: ensure test directory doesn't exist
|
||||
file:
|
||||
path: '{{ output_dir }}/non/existent/path'
|
||||
state: absent
|
||||
|
||||
- name: destination doesn't exist
|
||||
uri:
|
||||
url: 'https://{{ httpbin_host }}/get'
|
||||
dest: '{{ output_dir }}/non/existent/path'
|
||||
ignore_errors: true
|
||||
register: ret
|
||||
|
||||
- name: check that unexpected failure didn't happen
|
||||
assert:
|
||||
that:
|
||||
- ret is failed
|
||||
- "not ret.msg.startswith('MODULE FAILURE')"
|
||||
- '"Destination dir ''" ~ remote_dir_expanded ~ "/non/existent'' not writable" in ret.msg'
|
||||
- ret.status == 200
|
||||
Reference in New Issue
Block a user