diff options
Diffstat (limited to '')
5 files changed, 81 insertions, 0 deletions
diff --git a/test/integration/targets/yaml_parsing/aliases b/test/integration/targets/yaml_parsing/aliases new file mode 100644 index 0000000..1d28bdb --- /dev/null +++ b/test/integration/targets/yaml_parsing/aliases @@ -0,0 +1,2 @@ +shippable/posix/group5 +context/controller diff --git a/test/integration/targets/yaml_parsing/playbook.yml b/test/integration/targets/yaml_parsing/playbook.yml new file mode 100644 index 0000000..b3c9d5b --- /dev/null +++ b/test/integration/targets/yaml_parsing/playbook.yml @@ -0,0 +1,5 @@ +- hosts: localhost + gather_facts: false + vars: + foo: bar + foo: baz # yamllint disable rule:key-duplicates diff --git a/test/integration/targets/yaml_parsing/tasks/main.yml b/test/integration/targets/yaml_parsing/tasks/main.yml new file mode 100644 index 0000000..7d9c4aa --- /dev/null +++ b/test/integration/targets/yaml_parsing/tasks/main.yml @@ -0,0 +1,37 @@ +- name: Test ANSIBLE_DUPLICATE_YAML_DICT_KEY=warn + command: ansible-playbook {{ verbosity }} {{ role_path }}/playbook.yml + environment: + ANSIBLE_DUPLICATE_YAML_DICT_KEY: warn + register: duplicate_warn + +- assert: + that: + - '"found a duplicate dict key (foo)" in duplicate_warn.stderr' + - duplicate_warn.rc == 0 + +- name: Test ANSIBLE_DUPLICATE_YAML_DICT_KEY=error + command: ansible-playbook {{ verbosity }} {{ role_path }}/playbook.yml + failed_when: duplicate_error.rc != 4 + environment: + ANSIBLE_DUPLICATE_YAML_DICT_KEY: error + register: duplicate_error + +- assert: + that: + - '"found a duplicate dict key (foo)" in duplicate_error.stderr' + - duplicate_error.rc == 4 + +- name: Test ANSIBLE_DUPLICATE_YAML_DICT_KEY=ignore + command: ansible-playbook {{ verbosity }} {{ role_path }}/playbook.yml + environment: + ANSIBLE_DUPLICATE_YAML_DICT_KEY: ignore + register: duplicate_ignore + +- assert: + that: + - '"found a duplicate dict key (foo)" not in duplicate_ignore.stderr' + - duplicate_ignore.rc == 0 + + +- name: test unsafe YAMLism + import_tasks: unsafe.yml diff --git a/test/integration/targets/yaml_parsing/tasks/unsafe.yml b/test/integration/targets/yaml_parsing/tasks/unsafe.yml new file mode 100644 index 0000000..8d9d627 --- /dev/null +++ b/test/integration/targets/yaml_parsing/tasks/unsafe.yml @@ -0,0 +1,36 @@ +- name: ensure no templating unsafe + block: + - name: check unsafe string + assert: + that: + - regstr != resolved + - "'Fail' not in regstr" + - "'{' in regstr" + - "'}' in regstr" + vars: + regstr: !unsafe b{{nottemplate}} + + - name: check unsafe string in list + assert: + that: + - ulist[0] != resolved + - "'Fail' not in ulist[0]" + - "'{' in ulist[0]" + - "'}' in ulist[0]" + vars: + ulist: !unsafe [ 'b{{nottemplate}}', 'c', 'd'] + + - name: check unsafe string in dict + assert: + that: + - udict['a'] != resolved + - "'Fail' not in udict['a']" + - "'{' in udict['a']" + - "'}' in udict['a']" + vars: + udict: !unsafe + a: b{{nottemplate}} + c: d + vars: + nottemplate: FAIL + resolved: 'b{{nottemplate}}' diff --git a/test/integration/targets/yaml_parsing/vars/main.yml b/test/integration/targets/yaml_parsing/vars/main.yml new file mode 100644 index 0000000..ea65e0b --- /dev/null +++ b/test/integration/targets/yaml_parsing/vars/main.yml @@ -0,0 +1 @@ +verbosity: "{{ '' if not ansible_verbosity else '-' ~ ('v' * ansible_verbosity) }}" |