2014-06-19 18:32:43 +00:00
|
|
|
# test code for the win_get_url module
|
|
|
|
# (c) 2014, Chris Church <chris@ninemoreminutes.com>
|
|
|
|
|
|
|
|
# This file is part of Ansible
|
|
|
|
#
|
|
|
|
# Ansible is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# Ansible is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
2016-05-17 20:40:40 +00:00
|
|
|
- name: get tempdir path
|
|
|
|
raw: $env:TEMP
|
|
|
|
register: tempdir
|
|
|
|
|
|
|
|
- name: set output path dynamically
|
|
|
|
set_fact:
|
|
|
|
test_win_get_url_dir_path: "{{ tempdir.stdout_lines[0] }}"
|
|
|
|
|
2014-06-19 18:32:43 +00:00
|
|
|
- name: remove test file if it exists
|
2015-07-10 19:54:18 +00:00
|
|
|
raw: >
|
|
|
|
PowerShell -Command Remove-Item "{{test_win_get_url_path}}" -Force
|
|
|
|
ignore_errors: true
|
2014-06-19 18:32:43 +00:00
|
|
|
|
|
|
|
- name: test win_get_url module
|
2015-07-10 19:54:18 +00:00
|
|
|
win_get_url:
|
|
|
|
url: "{{test_win_get_url_link}}"
|
|
|
|
dest: "{{test_win_get_url_path}}"
|
2014-06-19 18:32:43 +00:00
|
|
|
register: win_get_url_result
|
|
|
|
|
2015-07-10 19:54:18 +00:00
|
|
|
- name: check that url was downloaded
|
2016-04-18 14:47:38 +00:00
|
|
|
assert:
|
2014-06-19 18:32:43 +00:00
|
|
|
that:
|
|
|
|
- "not win_get_url_result|failed"
|
|
|
|
- "win_get_url_result|changed"
|
2015-07-10 19:54:18 +00:00
|
|
|
- "win_get_url_result.win_get_url.url"
|
|
|
|
- "win_get_url_result.win_get_url.dest"
|
2014-06-19 18:32:43 +00:00
|
|
|
|
2015-07-10 19:54:18 +00:00
|
|
|
- name: test win_get_url module again (force should be yes by default)
|
|
|
|
win_get_url:
|
|
|
|
url: "{{test_win_get_url_link}}"
|
|
|
|
dest: "{{test_win_get_url_path}}"
|
|
|
|
register: win_get_url_result_again
|
|
|
|
|
|
|
|
- name: check that url was downloaded again
|
2016-04-18 14:47:38 +00:00
|
|
|
assert:
|
2015-07-10 19:54:18 +00:00
|
|
|
that:
|
|
|
|
- "not win_get_url_result_again|failed"
|
|
|
|
- "win_get_url_result_again|changed"
|
|
|
|
|
|
|
|
- name: test win_get_url module again with force=no
|
|
|
|
win_get_url:
|
|
|
|
url: "{{test_win_get_url_link}}"
|
|
|
|
dest: "{{test_win_get_url_path}}"
|
|
|
|
force: no
|
|
|
|
register: win_get_url_result_noforce
|
|
|
|
|
|
|
|
- name: check that url was not downloaded again
|
2016-04-18 14:47:38 +00:00
|
|
|
assert:
|
2015-07-10 19:54:18 +00:00
|
|
|
that:
|
|
|
|
- "not win_get_url_result_noforce|failed"
|
|
|
|
- "not win_get_url_result_noforce|changed"
|
|
|
|
|
|
|
|
- name: test win_get_url module with url that returns a 404
|
|
|
|
win_get_url:
|
|
|
|
url: "{{test_win_get_url_invalid_link}}"
|
|
|
|
dest: "{{test_win_get_url_path}}"
|
|
|
|
register: win_get_url_result_invalid_link
|
|
|
|
ignore_errors: true
|
|
|
|
|
|
|
|
- name: check that the download failed for an invalid url
|
2016-04-18 14:47:38 +00:00
|
|
|
assert:
|
2015-07-10 19:54:18 +00:00
|
|
|
that:
|
|
|
|
- "win_get_url_result_invalid_link|failed"
|
|
|
|
|
|
|
|
- name: test win_get_url module with an invalid path
|
|
|
|
win_get_url:
|
|
|
|
url: "{{test_win_get_url_link}}"
|
|
|
|
dest: "{{test_win_get_url_invalid_path}}"
|
|
|
|
register: win_get_url_result_invalid_path
|
|
|
|
ignore_errors: true
|
|
|
|
|
|
|
|
- name: check that the download failed for an invalid path
|
2016-04-18 14:47:38 +00:00
|
|
|
assert:
|
2015-07-10 19:54:18 +00:00
|
|
|
that:
|
|
|
|
- "win_get_url_result_invalid_path|failed"
|
|
|
|
|
|
|
|
- name: test win_get_url module with a valid path that is a directory
|
|
|
|
win_get_url:
|
|
|
|
url: "{{test_win_get_url_link}}"
|
|
|
|
dest: "{{test_win_get_url_dir_path}}"
|
|
|
|
register: win_get_url_result_dir_path
|
|
|
|
ignore_errors: true
|
|
|
|
|
|
|
|
- name: check that the download failed if dest is a directory
|
2016-04-18 14:47:38 +00:00
|
|
|
assert:
|
2015-07-10 19:54:18 +00:00
|
|
|
that:
|
|
|
|
- "win_get_url_result_dir_path|failed"
|