win_copy: fix for copying encrypted file without pass (#31084)

* win_copy: fix for copying encrypted file without pass

* fix pep8 issue

* reduced the diff and fixed some minor issues
This commit is contained in:
Jordan Borean 2017-10-04 06:51:57 +11:00 committed by Matt Davis
commit bba941cd5b
5 changed files with 63 additions and 10 deletions

View file

@ -26,6 +26,32 @@
register: fail_missing_parent_dir
failed_when: "'Destination directory ' + test_win_copy_path + '\\missing-dir does not exist' not in fail_missing_parent_dir.msg"
- name: fail to copy an encrypted file without the password set
win_copy:
src: '{{role_path}}/files-vault/vault-file'
dest: '{{test_win_copy_path}}\file'
register: fail_copy_encrypted_file
ignore_errors: yes # weird failed_when doesn't work in this case
- name: assert failure message when copying an encrypted file without the password set
assert:
that:
- fail_copy_encrypted_file|failed
- fail_copy_encrypted_file.msg == 'A vault password or secret must be specified to decrypt {{role_path}}/files-vault/vault-file'
- name: fail to copy a directory with an encrypted file without the password
win_copy:
src: '{{role_path}}/files-vault'
dest: '{{test_win_copy_path}}'
register: fail_copy_directory_with_enc_file
ignore_errors: yes
- name: assert failure message when copying a directory that contains an encrypted file without the password set
assert:
that:
- fail_copy_directory_with_enc_file|failed
- fail_copy_directory_with_enc_file.msg == 'A vault password or secret must be specified to decrypt {{role_path}}/files-vault/vault-file'
- name: copy with content (check mode)
win_copy:
content: a