summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorBrian Coca <bcoca@users.noreply.github.com>2022-10-26 17:05:03 -0400
committerGitHub <noreply@github.com>2022-10-26 16:05:03 -0500
commita5480c330db2645c213081955273610b98c67a6c (patch)
treedb155b8692a8d116e02c794d7dc245d133744005 /test
parent5dd04e54a8a29f830ce0459ebbe99143e8d62f1f (diff)
downloadansible-a5480c330db2645c213081955273610b98c67a6c.tar.gz
copy, avoid moving non temp remote 'non' files (#79102) (#79155)
* copy, avoid moving non temp remote files that are not dirs/files fix tests (cherry picked from commit f66016df0e22e1234417dc3538bea75299b4e9eb)
Diffstat (limited to 'test')
-rw-r--r--test/integration/targets/copy/tasks/main.yml3
-rw-r--r--test/integration/targets/copy/tasks/src_remote_file_is_not_file.yml39
2 files changed, 42 insertions, 0 deletions
diff --git a/test/integration/targets/copy/tasks/main.yml b/test/integration/targets/copy/tasks/main.yml
index a5211de1bd..7538e72fd5 100644
--- a/test/integration/targets/copy/tasks/main.yml
+++ b/test/integration/targets/copy/tasks/main.yml
@@ -97,6 +97,9 @@
- 'diff_output.diff[0].before == ""'
- '"Ansible managed" in diff_output.diff[0].after'
+ - name: tests with remote_src and non files
+ import_tasks: src_remote_file_is_not_file.yml
+
always:
- name: Cleaning
file:
diff --git a/test/integration/targets/copy/tasks/src_remote_file_is_not_file.yml b/test/integration/targets/copy/tasks/src_remote_file_is_not_file.yml
new file mode 100644
index 0000000000..2cda7d37c9
--- /dev/null
+++ b/test/integration/targets/copy/tasks/src_remote_file_is_not_file.yml
@@ -0,0 +1,39 @@
+- name: test remote src non files
+ vars:
+ destfile: '{{remote_dir}}/whocares'
+ block:
+ - name: mess with dev/null
+ copy:
+ src: /dev/null
+ dest: "{{destfile}}"
+ remote_src: true
+ become: true
+ register: dev_null_fail
+ ignore_errors: true
+
+ - name: ensure we failed
+ assert:
+ that:
+ - dev_null_fail is failed
+ - "'not a file' in dev_null_fail.msg"
+
+ - name: now with file existing
+ file: state=touch path="{{destfile}}"
+
+ - name: mess with dev/null again
+ copy:
+ src: /dev/null
+ dest: "{{destfile}}"
+ remote_src: true
+ become: true
+ register: dev_null_fail
+ ignore_errors: true
+
+ - name: ensure we failed, again
+ assert:
+ that:
+ - dev_null_fail is failed
+ - "'not a file' in dev_null_fail.msg"
+ always:
+ - name: cleanup
+ file: state=absent path="{{destfile}}"