blob: 83fd5db6d718fb3024bdb07ca6e7ebb38ec0c2ed (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
- name: Test that retrieving a url works
set_fact:
web_data: "{{ lookup('url', 'https://' ~ httpbin_host ~ '/get?one') }}"
- name: Assert that the url was retrieved
assert:
that:
- "'one' in web_data.args"
- name: Test that retrieving a url with invalid cert fails
set_fact:
web_data: "{{ lookup('url', 'https://' ~ badssl_host ~ '/') }}"
ignore_errors: True
register: url_invalid_cert
- assert:
that:
- "url_invalid_cert.failed"
- "'Error validating the server' in url_invalid_cert.msg or 'Hostname mismatch' in url_invalid_cert.msg or ( url_invalid_cert.msg is search('hostname .* doesn.t match .*'))"
- name: Test that retrieving a url with invalid cert with validate_certs=False works
set_fact:
web_data: "{{ lookup('url', 'https://' ~ badssl_host ~ '/', validate_certs=False) }}"
register: url_no_validate_cert
- assert:
that:
- badssl_host_substring in web_data
- vars:
url: https://{{ httpbin_host }}/get
block:
- name: test good cipher
debug:
msg: '{{ lookup("url", url) }}'
vars:
ansible_lookup_url_ciphers: ECDHE-RSA-AES128-SHA256
register: good_ciphers
- name: test bad cipher
debug:
msg: '{{ lookup("url", url) }}'
vars:
ansible_lookup_url_ciphers: ECDHE-ECDSA-AES128-SHA
ignore_errors: true
register: bad_ciphers
- assert:
that:
- good_ciphers is successful
- bad_ciphers is failed
- name: Test use_netrc=False
import_tasks: use_netrc.yml
- vars:
ansible_lookup_url_agent: ansible-test-lookup-url-agent
block:
- name: Test user agent
set_fact:
web_data: "{{ lookup('url', 'https://' ~ httpbin_host ~ '/user-agent') }}"
- name: Assert that user agent is set
assert:
that:
- ansible_lookup_url_agent in web_data['user-agent']
- vars:
ansible_lookup_url_force_basic_auth: yes
block:
- name: Test force basic auth
set_fact:
web_data: "{{ lookup('url', 'https://' ~ httpbin_host ~ '/headers', username='abc') }}"
- name: Assert that Authorization header is set
assert:
that:
- "'Authorization' in web_data.headers"
|