get_url should accept headers as a dict, instead of only a complicated string (#35470)

* get_url should accept headers as a dict, instead of only a complicated string

* update headers description text

* Add headers string and dict tests for get_url

* Add intg test for string header format parsing error

* Adjust deprecation version ahead 1 release, add the version dict format was added in to description
This commit is contained in:
Matt Martz 2018-04-10 11:50:39 -05:00 committed by GitHub
commit 0507c907a9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 45 additions and 5 deletions

View file

@ -230,10 +230,45 @@
#https://github.com/ansible/ansible/issues/16191
- name: Test url split with no filename
get_url:
get_url:
url: https://{{ httpbin_host }}
dest: "{{ output_dir }}"
- name: Test headers string
get_url:
url: https://{{ httpbin_host }}/headers
headers: Foo:bar,Baz:qux
dest: "{{ output_dir }}/headers_string.json"
- name: Test headers string
assert:
that:
- (lookup('file', output_dir ~ '/headers_string.json')|from_json).headers.get('Foo') == 'bar'
- (lookup('file', output_dir ~ '/headers_string.json')|from_json).headers.get('Baz') == 'qux'
- name: Test headers string invalid format
get_url:
url: https://{{ httpbin_host }}/headers
headers: Foo
dest: "{{ output_dir }}/headers_string_invalid.json"
register: invalid_string_headers
failed_when:
- invalid_string_headers is successful
- invalid_string_headers.msg != "The string representation for the `headers` parameter requires a key:value,key:value syntax to be properly parsed."
- name: Test headers dict
get_url:
url: https://{{ httpbin_host }}/headers
headers:
Foo: bar
Baz: qux
dest: "{{ output_dir }}/headers_dict.json"
- name: Test headers dict
assert:
that:
- (lookup('file', output_dir ~ '/headers_dict.json')|from_json).headers.get('Foo') == 'bar'
- (lookup('file', output_dir ~ '/headers_dict.json')|from_json).headers.get('Baz') == 'qux'
- name: Test client cert auth, with certs
get_url: