[stable-2.9] Don't treat no checksum as a checksum match (#62146)
Fixes #61978
* moar tests for get_url fetch behavior with existing file
* add changelog fragment
(cherry picked from commit 7d51cac
)
Co-authored-by: Matt Martz <matt@sivel.net>
This commit is contained in:
parent
f7fed1dacc
commit
20fee691e3
3 changed files with 39 additions and 12 deletions
3
changelogs/fragments/61978-get-url-no-checksum.yml
Normal file
3
changelogs/fragments/61978-get-url-no-checksum.yml
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
bugfixes:
|
||||||
|
- get_url - Don't treat no checksum as a checksum match
|
||||||
|
(https://github.com/ansible/ansible/issues/61978)
|
|
@ -540,7 +540,7 @@ def main():
|
||||||
checksum_mismatch = True
|
checksum_mismatch = True
|
||||||
|
|
||||||
# Not forcing redownload, unless checksum does not match
|
# Not forcing redownload, unless checksum does not match
|
||||||
if not force and not checksum_mismatch:
|
if not force and checksum and not checksum_mismatch:
|
||||||
# Not forcing redownload, unless checksum does not match
|
# Not forcing redownload, unless checksum does not match
|
||||||
# allow file attribute changes
|
# allow file attribute changes
|
||||||
module.params['path'] = dest
|
module.params['path'] = dest
|
||||||
|
|
|
@ -257,17 +257,6 @@
|
||||||
- result is changed
|
- result is changed
|
||||||
- "stat_result.stat.mode == '0775'"
|
- "stat_result.stat.mode == '0775'"
|
||||||
|
|
||||||
- name: Get a file that already exists
|
|
||||||
get_url:
|
|
||||||
url: 'https://{{ httpbin_host }}/get'
|
|
||||||
dest: '{{ remote_tmp_dir }}/test'
|
|
||||||
register: result
|
|
||||||
|
|
||||||
- name: Assert that we didn't re-download unnecessarily
|
|
||||||
assert:
|
|
||||||
that:
|
|
||||||
- result is not changed
|
|
||||||
|
|
||||||
- name: test checksum match in check mode
|
- name: test checksum match in check mode
|
||||||
get_url:
|
get_url:
|
||||||
url: 'https://{{ httpbin_host }}/get'
|
url: 'https://{{ httpbin_host }}/get'
|
||||||
|
@ -281,6 +270,41 @@
|
||||||
that:
|
that:
|
||||||
- result is not changed
|
- result is not changed
|
||||||
|
|
||||||
|
- name: Get a file that already exists with a checksum
|
||||||
|
get_url:
|
||||||
|
url: 'https://{{ httpbin_host }}/cache'
|
||||||
|
dest: '{{ remote_tmp_dir }}/test'
|
||||||
|
checksum: 'sha1:{{ stat_result.stat.checksum }}'
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- name: Assert that the file was not downloaded
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- result.msg == 'file already exists'
|
||||||
|
|
||||||
|
- name: Get a file that already exists
|
||||||
|
get_url:
|
||||||
|
url: 'https://{{ httpbin_host }}/cache'
|
||||||
|
dest: '{{ remote_tmp_dir }}/test'
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- name: Assert that we didn't re-download unnecessarily
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- result is not changed
|
||||||
|
- "'304' in result.msg"
|
||||||
|
|
||||||
|
- name: get a file that doesn't respond to If-Modified-Since without checksum
|
||||||
|
get_url:
|
||||||
|
url: 'https://{{ httpbin_host }}/get'
|
||||||
|
dest: '{{ remote_tmp_dir }}/test'
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- name: Assert that we downloaded the file
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- result is changed
|
||||||
|
|
||||||
# https://github.com/ansible/ansible/issues/27617
|
# https://github.com/ansible/ansible/issues/27617
|
||||||
|
|
||||||
- name: set role facts
|
- name: set role facts
|
||||||
|
|
Loading…
Reference in a new issue