From 37d1b3f1cf8cd70401deb609c804cbd0672a9cc5 Mon Sep 17 00:00:00 2001 From: Toshio Kuratomi Date: Wed, 10 Dec 2014 11:37:32 -0800 Subject: [PATCH] New test that binary contenti. (and a few unicode tests because they make clearer what we're testing) works. disabled for now since they mostly do not pass on 1.8. We'll want to enable them when we start integration testing the v2 tree. --- test/integration/non_destructive.yml | 2 + .../roles/test_binary/files/b64_latin1 | 1 + .../roles/test_binary/files/b64_utf8 | 1 + .../roles/test_binary/files/from_playbook | 1 + .../roles/test_binary/meta/main.yml | 3 + .../roles/test_binary/tasks/main.yml | 123 ++++++++++++++++++ .../templates/b64_latin1_template.j2 | 1 + .../templates/b64_utf8_template.j2 | 1 + .../templates/from_playbook_template.j2 | 1 + .../roles/test_binary/vars/main.yml | 3 + 10 files changed, 137 insertions(+) create mode 100644 test/integration/roles/test_binary/files/b64_latin1 create mode 100644 test/integration/roles/test_binary/files/b64_utf8 create mode 100644 test/integration/roles/test_binary/files/from_playbook create mode 100644 test/integration/roles/test_binary/meta/main.yml create mode 100644 test/integration/roles/test_binary/tasks/main.yml create mode 100644 test/integration/roles/test_binary/templates/b64_latin1_template.j2 create mode 100644 test/integration/roles/test_binary/templates/b64_utf8_template.j2 create mode 100644 test/integration/roles/test_binary/templates/from_playbook_template.j2 create mode 100644 test/integration/roles/test_binary/vars/main.yml diff --git a/test/integration/non_destructive.yml b/test/integration/non_destructive.yml index b177763fbf..e520a17ea0 100644 --- a/test/integration/non_destructive.yml +++ b/test/integration/non_destructive.yml @@ -39,4 +39,6 @@ - { role: test_authorized_key, tags: test_authorized_key } - { role: test_get_url, tags: test_get_url } - { role: test_embedded_module, tags: test_embedded_module } + # Turn on test_binary when we start testing v2 + #- { role: test_binary, tags: test_binary } diff --git a/test/integration/roles/test_binary/files/b64_latin1 b/test/integration/roles/test_binary/files/b64_latin1 new file mode 100644 index 0000000000..c7fbdeb632 --- /dev/null +++ b/test/integration/roles/test_binary/files/b64_latin1 @@ -0,0 +1 @@ +Café Eñe diff --git a/test/integration/roles/test_binary/files/b64_utf8 b/test/integration/roles/test_binary/files/b64_utf8 new file mode 100644 index 0000000000..c7fbdeb632 --- /dev/null +++ b/test/integration/roles/test_binary/files/b64_utf8 @@ -0,0 +1 @@ +Café Eñe diff --git a/test/integration/roles/test_binary/files/from_playbook b/test/integration/roles/test_binary/files/from_playbook new file mode 100644 index 0000000000..c7fbdeb632 --- /dev/null +++ b/test/integration/roles/test_binary/files/from_playbook @@ -0,0 +1 @@ +Café Eñe diff --git a/test/integration/roles/test_binary/meta/main.yml b/test/integration/roles/test_binary/meta/main.yml new file mode 100644 index 0000000000..1050c23ce3 --- /dev/null +++ b/test/integration/roles/test_binary/meta/main.yml @@ -0,0 +1,3 @@ +dependencies: + - prepare_tests + diff --git a/test/integration/roles/test_binary/tasks/main.yml b/test/integration/roles/test_binary/tasks/main.yml new file mode 100644 index 0000000000..dea1f85348 --- /dev/null +++ b/test/integration/roles/test_binary/tasks/main.yml @@ -0,0 +1,123 @@ +--- +# Various ways users want to use binary data +# Could integrate into individual modules but currently these don't all work. +# Probably easier to see them all in a single block to know what we're testing. +# When we can start testing v2 we should test that all of these work. + +# Expected values of the written files +- name: get checksums that we expect later files to have + copy: + src: from_playbook + dest: "{{ output_dir }}" + +- copy: + src: b64_utf8 + dest: "{{ output_dir }}" + +- copy: + src: b64_latin1 + dest: "{{ output_dir }}" + +- stat: + path: "{{ output_dir }}/from_playbook" + register: from_playbook + +- stat: + path: "{{ output_dir }}/b64_utf8" + register: b64_utf8 + +- stat: + path: "{{ output_dir }}/b64_latin1" + register: b64_latin1 + +- name: copy with utf-8 content in a playbook + copy: + content: "{{ simple_accents }}\n" + dest: "{{ output_dir }}/from_playbook.txt" + +- name: Check that what was written matches + stat: + path: "{{ output_dir }}/from_playbook.txt" + register: results + +- assert: + that: + - 'results.stat.checksum == from_playbook.stat.checksum' + ignore_errors: True + +- name: copy with utf8 in a base64 encoded string + copy: + content: "{{ utf8_simple_accents|b64decode }}\n" + dest: "{{ output_dir }}/b64_utf8.txt" + +- name: Check that what was written matches + stat: + path: "{{ output_dir }}/b64_utf8.txt" + register: results + +- assert: + that: + - 'results.stat.checksum == b64_utf8.stat.checksum' + ignore_errors: True + +#- name: copy with latin1 in a base64 encoded string +# copy: +# content: "{{ latin1_simple_accents|b64decode }}\n" +# dest: "{{ output_dir }}/b64_latin1.txt" +# +#- name: Check that what was written matches +# stat: +# path: "{{ output_dir }}/b64_latin1.txt" +# register: results +# +#- assert: +# that: +# - 'results.stat.checksum == b64_latin1.stat.checksum' +# ignore_errors: True + +- name: Template with a unicode string from the playbook + template: + src: "from_playbook_template.j2" + dest: "{{ output_dir }}/from_playbook_template.txt" + +- name: Check that what was written matches + stat: + path: "{{ output_dir }}/from_playbook_template.txt" + register: results + +- assert: + that: + - 'results.stat.checksum == from_playbook.stat.checksum' + +- name: Template with utf8 in a base64 encoded string + template: + src: "b64_utf8_template.j2" + dest: "{{ output_dir }}/b64_utf8_template.txt" + +- name: Check that what was written matches + stat: + path: "{{ output_dir }}/b64_utf8_template.txt" + register: results + +- assert: + that: + - 'results.stat.checksum == b64_utf8.stat.checksum' + +#- name: Template with latin1 in a base64 encoded string +# template: +# src: "b64_latin1_template.j2" +# dest: "{{ output_dir }}/b64_latin1_template.txt" +# +#- name: Check that what was written matches +# stat: +# path: "{{ output_dir }}/b64_latin1_template.txt" +# register: results +# +#- assert: +# that: +# - 'results.stat.checksum == b64_latin1.stat.checksum' + +# These might give garbled output but none of them should traceback +- debug: var=simple_accents +- debug: msg={{ utf8_simple_accents|b64decode}} +#- debug: msg={{ latin1_simple_accents|b64decode}} diff --git a/test/integration/roles/test_binary/templates/b64_latin1_template.j2 b/test/integration/roles/test_binary/templates/b64_latin1_template.j2 new file mode 100644 index 0000000000..ee2fc1b19c --- /dev/null +++ b/test/integration/roles/test_binary/templates/b64_latin1_template.j2 @@ -0,0 +1 @@ +{{ latin1_simple_accents|b64decode }} diff --git a/test/integration/roles/test_binary/templates/b64_utf8_template.j2 b/test/integration/roles/test_binary/templates/b64_utf8_template.j2 new file mode 100644 index 0000000000..9fd3ed48b1 --- /dev/null +++ b/test/integration/roles/test_binary/templates/b64_utf8_template.j2 @@ -0,0 +1 @@ +{{ utf8_simple_accents|b64decode }} diff --git a/test/integration/roles/test_binary/templates/from_playbook_template.j2 b/test/integration/roles/test_binary/templates/from_playbook_template.j2 new file mode 100644 index 0000000000..3be6dd4f0b --- /dev/null +++ b/test/integration/roles/test_binary/templates/from_playbook_template.j2 @@ -0,0 +1 @@ +{{ simple_accents }} diff --git a/test/integration/roles/test_binary/vars/main.yml b/test/integration/roles/test_binary/vars/main.yml new file mode 100644 index 0000000000..f6d40232c3 --- /dev/null +++ b/test/integration/roles/test_binary/vars/main.yml @@ -0,0 +1,3 @@ +simple_accents: 'Café Eñe' +utf8_simple_accents: 'Q2Fmw6kgRcOxZQ==' +latin1_simple_accents: 'Q2Fm6SBF8WU='