Debian Codegraph @

test/integration/targets/lookup_url/tasks/main.yml

raw
1 - name: Test that retrieving a url works
2 set_fact:
3 web_data: "{{ lookup('url', 'https://' ~ httpbin_host ~ '/get?one') | from_json }}"
4
5 - name: Assert that the url was retrieved
6 assert:
7 that:
8 - "'one' in web_data.args"
9
10 - name: Test that retrieving a url with invalid cert fails
11 set_fact:
12 web_data: "{{ lookup('url', 'https://' ~ badssl_host ~ '/') }}"
13 ignore_errors: True
14 register: url_invalid_cert
15
16 - assert:
17 that:
18 - "url_invalid_cert.failed"
19 - "'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 .*'))"
20
21 - name: Test that retrieving a url with invalid cert with validate_certs=False works
22 set_fact:
23 web_data: "{{ lookup('url', 'https://' ~ badssl_host ~ '/', validate_certs=False) }}"
24 register: url_no_validate_cert
25
26 - assert:
27 that:
28 - badssl_host_substring in web_data
29
30 - name: Test ciphers
31 import_tasks: ciphers.yml
32 when: false # skipped until we have a way to disable TLS 1.3 on the client or server, since cipher suite selection won't break TLS 1.3
33
34 - name: Test use_netrc=False
35 import_tasks: use_netrc.yml
36
37 - vars:
38 ansible_lookup_url_agent: ansible-test-lookup-url-agent
39 block:
40 - name: Test user agent
41 set_fact:
42 web_data: "{{ lookup('url', 'https://' ~ httpbin_host ~ '/user-agent') | from_json }}"
43
44 - name: Assert that user agent is set
45 assert:
46 that:
47 - ansible_lookup_url_agent in web_data['user-agent']
48
49 - vars:
50 ansible_lookup_url_force_basic_auth: yes
51 block:
52 - name: Test force basic auth
53 set_fact:
54 web_data: "{{ lookup('url', 'https://' ~ httpbin_host ~ '/headers', username='abc') | from_json }}"
55
56 - name: Assert that Authorization header is set
57 assert:
58 that:
59 - "'Authorization' in web_data.headers"