2019-03-05 11:37:00 +01:00
---
2019-03-13 23:04:49 +01:00
# These files are pre formatted and we want to get the base64 value so we can use it for httpbin
# dynamic content in checksum_url
- name : set base64 values for checksum files
set_fact :
sha1sum : '{{ lookup("file", "ftp/anon/sha1sum.txt") | b64encode }}'
sha256sum : '{{ lookup("file", "ftp/anon/sha256sum.txt") | b64encode }}'
sha256sum_dot : '{{ lookup("file", "ftp/anon/sha256sum_with_dot.txt") | b64encode }}'
- name : download file with sha1 checksum url
2019-03-05 11:37:00 +01:00
win_get_url :
2019-03-13 23:04:49 +01:00
url : https://{{ httpbin_host }}/base64/cHR1eA==
2019-03-19 03:01:35 +01:00
dest : '{{ testing_dir }}\sha1.txt'
2019-03-13 23:04:49 +01:00
checksum_url : https://{{ httpbin_host }}/base64/{{ sha1sum }}
2019-03-05 11:37:00 +01:00
force : True
2019-03-13 23:04:49 +01:00
register : download_sha1_url
2019-03-05 11:37:00 +01:00
2019-03-13 23:04:49 +01:00
- name : download file with sha1 checksum value
2019-03-05 11:37:00 +01:00
win_get_url :
2019-03-13 23:04:49 +01:00
url : https://{{ httpbin_host }}/base64/cHR1eA==
2019-03-19 03:01:35 +01:00
dest : '{{ testing_dir }}\sha1.txt'
2019-03-13 23:04:49 +01:00
checksum : a97e6837f60cec6da4491bab387296bbcd72bdba
2019-03-05 11:37:00 +01:00
force : True
2019-03-13 23:04:49 +01:00
register : download_sha1_value
2019-03-05 11:37:00 +01:00
2019-03-13 23:04:49 +01:00
- name : assert download file with sha1 checksum
assert :
that :
- download_sha1_url is changed
- download_sha1_url.status_code == 200
- download_sha1_url.checksum_dest == 'a97e6837f60cec6da4491bab387296bbcd72bdba'
- not download_sha1_value is changed
- download_sha1_value.status_code == 200
- download_sha1_value.checksum_dest == 'a97e6837f60cec6da4491bab387296bbcd72bdba'
- name : download file with sha256 checksum ftp
2019-03-05 11:37:00 +01:00
win_get_url :
2019-03-13 23:04:49 +01:00
url : https://{{ httpbin_host }}/base64/cHR1eA==
2019-03-19 03:01:35 +01:00
dest : '{{ testing_dir }}\sha256.txt'
2019-03-13 23:04:49 +01:00
checksum_url : ftp://localhost/anon/sha256sum.txt # tests that a checksum can be from an FTP URI
2019-03-05 11:37:00 +01:00
checksum_algorithm : sha256
force : True
2019-03-13 23:04:49 +01:00
register : download_sha256_ftp
2019-03-05 11:37:00 +01:00
2019-03-13 23:04:49 +01:00
- name : download file with sha256 checksum dot leading source as file
2019-03-05 11:37:00 +01:00
win_get_url :
2019-03-13 23:04:49 +01:00
url : https://{{ httpbin_host }}/base64/cHR1eA==
2019-03-19 03:01:35 +01:00
dest : '{{ testing_dir }}\sha256.txt'
checksum_url : '{{ testing_dir }}\ftp\anon\sha256sum_with_dot.txt'
2019-03-05 11:37:00 +01:00
checksum_algorithm : sha256
force : True
2019-03-13 23:04:49 +01:00
register : download_sha256_file
2019-03-05 11:37:00 +01:00
2019-03-13 23:04:49 +01:00
- name : download file with sha256 checksum value
2019-03-05 11:37:00 +01:00
win_get_url :
2019-03-13 23:04:49 +01:00
url : https://{{ httpbin_host }}/base64/cHR1eA==
2019-03-19 03:01:35 +01:00
dest : '{{ testing_dir }}\sha256.txt'
2019-03-13 23:04:49 +01:00
checksum : b1b6ce5073c8fac263a8fc5edfffdbd5dec1980c784e09c5bc69f8fb6056f006
2019-03-05 11:37:00 +01:00
checksum_algorithm : sha256
2019-03-13 23:04:49 +01:00
register : download_sha256_value
2019-03-05 11:37:00 +01:00
2019-03-13 23:04:49 +01:00
- name : assert download file with sha256 checksum
2019-03-05 11:37:00 +01:00
assert :
that :
2019-03-13 23:04:49 +01:00
- download_sha256_ftp is changed
- download_sha256_ftp.status_code == 200
- download_sha256_ftp.checksum_dest == 'b1b6ce5073c8fac263a8fc5edfffdbd5dec1980c784e09c5bc69f8fb6056f006'
- not download_sha256_file is changed
- download_sha256_file.status_code == 200
- download_sha256_file.checksum_dest == 'b1b6ce5073c8fac263a8fc5edfffdbd5dec1980c784e09c5bc69f8fb6056f006'
- not download_sha256_value is changed
- download_sha256_value.status_code == 200
- download_sha256_value.checksum_dest == 'b1b6ce5073c8fac263a8fc5edfffdbd5dec1980c784e09c5bc69f8fb6056f006'
- name : fail download with invalid checksum and force=no
2019-03-05 11:37:00 +01:00
win_get_url :
2019-03-13 23:04:49 +01:00
url : https://{{ httpbin_host }}/base64/cHR1eA==
2019-03-19 03:01:35 +01:00
dest : '{{ testing_dir }}\fail.txt'
2019-03-13 23:04:49 +01:00
checksum : invalid
force : no
register : fail_checksum_force_no
failed_when : fail_checksum_force_no.msg != "The checksum for https://" + httpbin_host + "/base64/cHR1eA== did not match 'invalid', it was 'a97e6837f60cec6da4491bab387296bbcd72bdba'"
- name : fail download with invalid checksum and force=yes
2019-03-05 11:37:00 +01:00
win_get_url :
2019-03-13 23:04:49 +01:00
url : https://{{ httpbin_host }}/base64/cHR1eA==
2019-03-19 03:01:35 +01:00
dest : '{{ testing_dir }}\fail.txt'
2019-03-13 23:04:49 +01:00
checksum : invalid
force : yes
register : fail_checksum_force_yes
failed_when : fail_checksum_force_yes.msg != "The checksum for https://" + httpbin_host + "/base64/cHR1eA== did not match 'invalid', it was 'a97e6837f60cec6da4491bab387296bbcd72bdba'"