diff --git a/test/integration/targets/parsing/bad_parsing.yml b/test/integration/targets/parsing/bad_parsing.yml deleted file mode 100644 index 953ec072ae8..00000000000 --- a/test/integration/targets/parsing/bad_parsing.yml +++ /dev/null @@ -1,12 +0,0 @@ -- hosts: testhost - - # the following commands should all parse fine and execute fine - # and represent quoting scenarios that should be legit - - gather_facts: False - - roles: - - # this one has a lot of things that should fail, see makefile for operation w/ tags - - - { role: test_bad_parsing } diff --git a/test/integration/targets/parsing/parsing.yml b/test/integration/targets/parsing/parsing.yml new file mode 100644 index 00000000000..9d5ff41a86c --- /dev/null +++ b/test/integration/targets/parsing/parsing.yml @@ -0,0 +1,35 @@ +- hosts: testhost + gather_facts: no + tasks: + - name: test that a variable cannot inject raw arguments + shell: echo hi {{ chdir }} + vars: + chdir: mom chdir=/tmp + register: raw_injection + + - name: test that a variable cannot inject kvp arguments as a kvp + file: path={{ test_file }} {{ test_input }} + vars: + test_file: "{{ output_dir }}/ansible_test_file" + test_input: "owner=test" + register: kvp_kvp_injection + ignore_errors: yes + + - name: test that a variable cannot inject kvp arguments as a value + file: state=absent path='{{ kvp_in_var }}' + vars: + kvp_in_var: "{{ output_dir }}' owner='test" + register: kvp_value_injection + + - name: test that a missing filter fails + debug: + msg: "{{ output_dir | badfiltername }}" + register: filter_missing + ignore_errors: yes + + - assert: + that: + - raw_injection.stdout == 'hi mom chdir=/tmp' + - kvp_kvp_injection is failed + - kvp_value_injection.path.endswith("' owner='test") + - filter_missing is failed diff --git a/test/integration/targets/parsing/roles/test_bad_parsing/tasks/main.yml b/test/integration/targets/parsing/roles/test_bad_parsing/tasks/main.yml deleted file mode 100644 index f1b2ec6a050..00000000000 --- a/test/integration/targets/parsing/roles/test_bad_parsing/tasks/main.yml +++ /dev/null @@ -1,60 +0,0 @@ -# test code for the ping module -# (c) 2014, Michael DeHaan - -# This file is part of Ansible -# -# Ansible is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Ansible is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with Ansible. If not, see . - -# the following tests all raise errors, to use them in a Makefile, we run them with different flags, as -# otherwise ansible stops at the first one and we want to ensure STOP conditions for each - -- set_fact: - test_file: "{{ output_dir }}/ansible_test_file" # FIXME, use set tempdir - test_input: "owner=test" - bad_var: "{{ output_dir }}' owner=test" - chdir: "mom chdir=/tmp" - tags: common - -- file: name={{test_file}} state=touch - tags: common - -- name: remove touched file - file: name={{test_file}} state=absent - tags: common - -- name: include test that we cannot insert arguments - include: scenario1.yml - tags: scenario1 - -- name: include test that we cannot duplicate arguments - include: scenario2.yml - tags: scenario2 - -- name: include test that we can't do this for the shell module - include: scenario3.yml - tags: scenario3 - -- name: include test that we can't go all Little Bobby Droptables on a quoted var to add more - include: scenario4.yml - tags: scenario4 - -- name: test that a missing/malformed jinja2 filter fails - debug: msg="{{output_dir|badfiltername}}" - tags: scenario5 - register: filter_fail - ignore_errors: yes - -- assert: - that: - - filter_fail is failed diff --git a/test/integration/targets/parsing/roles/test_bad_parsing/tasks/scenario1.yml b/test/integration/targets/parsing/roles/test_bad_parsing/tasks/scenario1.yml deleted file mode 100644 index 8a82fb95dd4..00000000000 --- a/test/integration/targets/parsing/roles/test_bad_parsing/tasks/scenario1.yml +++ /dev/null @@ -1,4 +0,0 @@ -- name: test that we cannot insert arguments - file: path={{ test_file }} {{ test_input }} - failed_when: False # ignore the module, just test the parser - tags: scenario1 diff --git a/test/integration/targets/parsing/roles/test_bad_parsing/tasks/scenario2.yml b/test/integration/targets/parsing/roles/test_bad_parsing/tasks/scenario2.yml deleted file mode 100644 index c3b4b13c1a6..00000000000 --- a/test/integration/targets/parsing/roles/test_bad_parsing/tasks/scenario2.yml +++ /dev/null @@ -1,4 +0,0 @@ -- name: test that we cannot duplicate arguments - file: path={{ test_file }} owner=test2 {{ test_input }} - failed_when: False # ignore the module, just test the parser - tags: scenario2 diff --git a/test/integration/targets/parsing/roles/test_bad_parsing/tasks/scenario3.yml b/test/integration/targets/parsing/roles/test_bad_parsing/tasks/scenario3.yml deleted file mode 100644 index a228f70e213..00000000000 --- a/test/integration/targets/parsing/roles/test_bad_parsing/tasks/scenario3.yml +++ /dev/null @@ -1,4 +0,0 @@ -- name: test that we can't do this for the shell module - shell: echo hi {{ chdir }} - failed_when: False - tags: scenario3 diff --git a/test/integration/targets/parsing/roles/test_bad_parsing/tasks/scenario4.yml b/test/integration/targets/parsing/roles/test_bad_parsing/tasks/scenario4.yml deleted file mode 100644 index 2845adca468..00000000000 --- a/test/integration/targets/parsing/roles/test_bad_parsing/tasks/scenario4.yml +++ /dev/null @@ -1,4 +0,0 @@ -- name: test that we can't go all Little Bobby Droptables on a quoted var to add more - file: "name={{ bad_var }}" - failed_when: False - tags: scenario4 diff --git a/test/integration/targets/parsing/roles/test_bad_parsing/vars/main.yml b/test/integration/targets/parsing/roles/test_bad_parsing/vars/main.yml deleted file mode 100644 index 1aaeac77306..00000000000 --- a/test/integration/targets/parsing/roles/test_bad_parsing/vars/main.yml +++ /dev/null @@ -1,2 +0,0 @@ ---- -output_dir: . diff --git a/test/integration/targets/parsing/runme.sh b/test/integration/targets/parsing/runme.sh index 022ce4cf397..2d550082c7d 100755 --- a/test/integration/targets/parsing/runme.sh +++ b/test/integration/targets/parsing/runme.sh @@ -2,5 +2,5 @@ set -eux -ansible-playbook bad_parsing.yml -i ../../inventory -vvv "$@" --tags prepare,common,scenario5 -ansible-playbook good_parsing.yml -i ../../inventory -v "$@" +ansible-playbook parsing.yml -i ../../inventory "$@" -e "output_dir=${OUTPUT_DIR}" +ansible-playbook good_parsing.yml -i ../../inventory "$@"