mirror of https://github.com/ansible/ansible.git
do not return the body even if it failed (#69706)
* do not return the body even if it failed * add some tests for this and rebase * import test task * ignore_errors when fails Co-authored-by: Jack Zhang <jack.zhang@aspiraconnect.com>pull/69805/head
parent
723a904f4e
commit
80f09efd03
@ -0,0 +1,3 @@
|
|||||||
|
bugfixes:
|
||||||
|
- uri - Don't return the body even if it failed
|
||||||
|
(https://github.com/ansible/ansible/issues/21003)
|
@ -0,0 +1,49 @@
|
|||||||
|
- name: Test when return_content is yes
|
||||||
|
uri:
|
||||||
|
url: https://{{ httpbin_host }}/get
|
||||||
|
return_content: yes
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- name: Assert content exists when return_content is yes and request succeeds
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- result is successful
|
||||||
|
- "'content' in result"
|
||||||
|
|
||||||
|
- name: Test when return_content is yes
|
||||||
|
uri:
|
||||||
|
url: http://does/not/exist
|
||||||
|
return_content: yes
|
||||||
|
register: result
|
||||||
|
ignore_errors: true
|
||||||
|
|
||||||
|
- name: Assert content exists when return_content is yes and request fails
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- result is failed
|
||||||
|
- "'content' in result"
|
||||||
|
|
||||||
|
- name: Test when return_content is no
|
||||||
|
uri:
|
||||||
|
url: https://{{ httpbin_host }}/get
|
||||||
|
return_content: no
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- name: Assert content does not exist when return_content is no and request succeeds
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- result is successful
|
||||||
|
- "'content' not in result"
|
||||||
|
|
||||||
|
- name: Test when return_content is no
|
||||||
|
uri:
|
||||||
|
url: http://does/not/exist
|
||||||
|
return_content: no
|
||||||
|
register: result
|
||||||
|
ignore_errors: true
|
||||||
|
|
||||||
|
- name: Assert content does not exist when return_content is no and request fails
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- result is failed
|
||||||
|
- "'content' not in result"
|
Loading…
Reference in New Issue