1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00
community.general/test/integration/targets/win_get_url/tasks/tests_url.yml
Viktor Utkin b2a7561a7f [win_get_url] feature: Add support checksum to module win_get_url (#51986)
* set valid_until equal to current time + spot_wait_timeout

* Add checksum check for downloaded file.

* refactoring

* fix typo

* add fixes

* mart try,catch handling

* revert lib/ansible/modules/cloud/amazon/ec2.py from upstream

* refactoring

* remove empty lines

* add checksum verification for existing file

* fix current file check

* refactoring destination file check

* add handling exceptions

* refactoring

* Added download file hash data from url

* fix string aligning

* fix bug with uri

* Added get hash from multy-string file

* Added URI support for checksum file location

* refactoing

* Remove any non-alphanumeric characters for hash from url

* fix discussions; add support for PS3

* refactoring

* add size return value

* checkout from upstream for lib/ansible/modules/cloud/amazon/ec2.py

* add Ansible.ModuleUtils.Legacy support; refactoring

* Copyright added

* Checking files size before and after downloading added.

* remove unused code

* Corrected regexp for dotted slashed file name prefix in hash-file

* hotfix typo error; add int tests

* remove legacy module support; split checksum to checksum, checksum_algorithm, checksum_url

* changed default hash algorithm

* Fixed case for ContentLength = -1

* Old comment removed

* fix typo

* Remove file size check before downloading

* add alias to ; fix tests

* adjust tests; fix lint warnings from PSScritpAnalyzer

* workaround for bug in win_chocolatey module on win2008

* remove win_get_url.ps1 from /test/sanity/pslint/ignore.txt

* add checksum_algorithm as retuen value

* first normalise before return Result

* resolve discussions

Signed-off-by: Viktor Utkin <viktor.utkin7@yandex.ru>

* fix discussions
fix http tests as discussed

* fix last discussions

* Reduce code duplication and add idempotency check

* fix sanity issue and remove testing code

* move back to using tmp file for checksum comparison
2019-03-05 20:37:00 +10:00

135 lines
3.9 KiB
YAML

- name: download single file (check)
win_get_url:
url: https://{{test_win_get_url_host}}
dest: '{{test_win_get_url_path}}\web.html'
check_mode: yes
register: http_download_check
- name: get result of download single file (check)
win_stat:
path: '{{test_win_get_url_path}}\web.html'
register: http_download_result_check
- name: assert download single file (check)
assert:
that:
- http_download_check is not failed
- http_download_check is changed
- http_download_check.url
- http_download_check.dest
- not http_download_result_check.stat.exists
- name: download single file
win_get_url:
url: https://{{test_win_get_url_host}}
dest: '{{test_win_get_url_path}}\web.html'
register: http_download
- name: get result of download single file
win_stat:
path: '{{test_win_get_url_path}}\web.html'
register: http_download_result
- name: assert download single file
assert:
that:
- http_download is not failed
- http_download is changed
- http_download.url
- http_download.dest
- http_download_result.stat.exists
- name: download single file (idempotent)
win_get_url:
url: https://{{test_win_get_url_host}}
dest: '{{test_win_get_url_path}}\web.html'
register: http_download_again
- name: assert download single file (idempotent)
assert:
that:
- not http_download_again is changed
- name: download single file with force no
win_get_url:
url: https://{{test_win_get_url_host}}
dest: '{{test_win_get_url_path}}\web.html'
force: no
register: http_download_no_force
- name: assert download single file with force no
assert:
that:
- http_download_no_force is not changed
- name: manually change the content and last modified time on FTP source to older datetime
win_shell: |
Set-Content -Path '{{test_win_get_url_path}}\web.html' -Value 'abc'
(Get-Item -Path '{{test_win_get_url_path}}\web.html').LastWriteTime = (Get-Date -Date "01/01/1970")
- name: download newer file with force no
win_get_url:
url: https://{{test_win_get_url_host}}
dest: '{{test_win_get_url_path}}\web.html'
force: no
register: http_download_newer_no_force
- name: assert download newer file with force no
assert:
that:
- http_download_newer_no_force is changed
- name: download file to directory
win_get_url:
url: https://{{test_win_get_url_host}}
dest: '{{test_win_get_url_path}}'
register: http_download_to_directory
- name: get result of download to directory
win_stat:
path: '{{test_win_get_url_path}}\{{test_win_get_url_host}}'
register: http_download_to_directory_result
- name: assert download file to directory
assert:
that:
- http_download_to_directory is changed
- http_download_to_directory_result.stat.exists
- name: download to path with env var
win_get_url:
url: https://{{test_win_get_url_host}}
dest: '%{{test_win_get_url_env_var}}%\http-env.html'
register: http_download_with_env
- name: get result of download to path with env var
win_stat:
path: '{{test_win_get_url_path}}\http-env.html'
register: http_download_with_env_result
- name: assert download to path with env var
assert:
that:
- http_download_with_env is changed
- http_download_with_env_result.stat.exists
- name: fail when link returns 404
win_get_url:
url: https://{{test_win_get_url_host}}/skynet_module.html
dest: '{{test_win_get_url_path}}\skynet_module.html'
ignore_errors: yes
register: fail_download_404
- name: assert fail when link returns 404
assert:
that:
- fail_download_404 is not changed
- fail_download_404 is failed
- fail_download_404.status_code == 404
- name: fail when dest is an invalid path
win_get_url:
url: https://{{test_win_get_url_host}}
dest: Q:\Filez\Cyberdyne.html
register: fail_invalid_path
failed_when: '"The path ''Q:\Filez'' does not exist for destination ''Q:\Filez\Cyberdyne.html''" not in fail_invalid_path.msg'