diff --git a/test/integration/targets/filter_urls/runme.sh b/test/integration/targets/filter_urls/runme.sh new file mode 100755 index 00000000000..f6460acb33b --- /dev/null +++ b/test/integration/targets/filter_urls/runme.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env bash + +set -eux + +export ANSIBLE_ROLES_PATH=../ + +ansible-playbook runme.yml "$@" + +source virtualenv.sh + +# This is necessary for installing Jinja 2.6. We need this because Jinja 2.6 +# won't install with newer setuptools, and because setuptools 45+ won't work +# with Python 2. +pip install 'setuptools<45' + +# Install Jinja 2.6 since we want to test the fallback to Ansible's custom +# urlencode functions. Jinja 2.6 does not have urlencode so we will trigger the +# fallback. +pip install 'jinja2 >= 2.6, < 2.7' + +# Run the playbook again in the venv with Jinja 2.6 +ansible-playbook runme.yml "$@" diff --git a/test/integration/targets/filter_urls/runme.yml b/test/integration/targets/filter_urls/runme.yml new file mode 100644 index 00000000000..527a03e357a --- /dev/null +++ b/test/integration/targets/filter_urls/runme.yml @@ -0,0 +1,4 @@ +- hosts: localhost + gather_facts: false + roles: + - { role: filter_urls } diff --git a/test/integration/targets/filter_urls/tasks/main.yml b/test/integration/targets/filter_urls/tasks/main.yml index 59d55d9092a..935ed479fdd 100644 --- a/test/integration/targets/filter_urls/tasks/main.yml +++ b/test/integration/targets/filter_urls/tasks/main.yml @@ -1,12 +1,31 @@ +- name: Get Jinja2 version + shell: "{{ ansible_python_interpreter }} -c 'import jinja2; print(jinja2.__version__)'" + register: jinja2_version + +- name: Print Jinja2 version + debug: var=jinja2_version.stdout + - name: Test urldecode filter set_fact: urldecoded_string: key="@{}é&%£ foo bar '(;\<>""°) - name: Test urlencode filter set_fact: - urlencoded_string: '{{ urldecoded_string|urlencode }}' + urlencoded_string: 'key%3D%22%40%7B%7D%C3%A9%26%25%C2%A3%20foo%20bar%20%27%28%3B%5C%3C%3E%22%22%C2%B0%29' -- name: Verify urlencode en urldecode +- name: Verify urlencode / urldecode isomorphism assert: that: - urldecoded_string == urlencoded_string|urldecode + - urlencoded_string == urldecoded_string|urlencode + +- name: Verify urlencode handles dicts properly + assert: + that: + - "{'foo': 'bar'}|urlencode == 'foo=bar'" + - "{'foo': 'bar', 'baz': 'buz'}|urlencode == 'foo=bar&baz=buz'" + - "()|urlencode == ''" + +# Needed (temporarily) due to coverage reports not including the last task. +- assert: + that: true