summaryrefslogtreecommitdiffstats
path: root/test/integration/targets/uri
diff options
context:
space:
mode:
authorJack <zhan9san@163.com>2020-06-01 15:55:38 +0200
committerGitHub <noreply@github.com>2020-06-01 15:55:38 +0200
commit80f09efd03c934ba9780f141adfdb0d7aad18b12 (patch)
tree6c028ff86169b4d45342ab52c550a938c0e2ad2a /test/integration/targets/uri
parentHandle disabled service units (#69349) (diff)
downloadansible-80f09efd03c934ba9780f141adfdb0d7aad18b12.tar.xz
ansible-80f09efd03c934ba9780f141adfdb0d7aad18b12.zip
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>
Diffstat (limited to 'test/integration/targets/uri')
-rw-r--r--test/integration/targets/uri/tasks/main.yml3
-rw-r--r--test/integration/targets/uri/tasks/return-content.yml49
2 files changed, 52 insertions, 0 deletions
diff --git a/test/integration/targets/uri/tasks/main.yml b/test/integration/targets/uri/tasks/main.yml
index de41e0117c..409607af32 100644
--- a/test/integration/targets/uri/tasks/main.yml
+++ b/test/integration/targets/uri/tasks/main.yml
@@ -595,3 +595,6 @@
- name: Check unexpected failures
import_tasks: unexpected-failures.yml
+
+- name: Check return-content
+ import_tasks: return-content.yml
diff --git a/test/integration/targets/uri/tasks/return-content.yml b/test/integration/targets/uri/tasks/return-content.yml
new file mode 100644
index 0000000000..5a9b97e641
--- /dev/null
+++ b/test/integration/targets/uri/tasks/return-content.yml
@@ -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" \ No newline at end of file