From 8a754e0858d922e955e71b253c139e071ecec432 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 28 Apr 2024 18:04:21 +0200 Subject: Adding upstream version 2.14.3. Signed-off-by: Daniel Baumann --- test/integration/targets/binary/aliases | 2 + test/integration/targets/binary/files/b64_latin1 | 1 + test/integration/targets/binary/files/b64_utf8 | 1 + .../integration/targets/binary/files/from_playbook | 1 + test/integration/targets/binary/meta/main.yml | 3 + test/integration/targets/binary/tasks/main.yml | 131 +++++++++++++++++++++ .../binary/templates/b64_latin1_template.j2 | 1 + .../targets/binary/templates/b64_utf8_template.j2 | 1 + .../binary/templates/from_playbook_template.j2 | 1 + test/integration/targets/binary/vars/main.yml | 3 + 10 files changed, 145 insertions(+) create mode 100644 test/integration/targets/binary/aliases create mode 100644 test/integration/targets/binary/files/b64_latin1 create mode 100644 test/integration/targets/binary/files/b64_utf8 create mode 100644 test/integration/targets/binary/files/from_playbook create mode 100644 test/integration/targets/binary/meta/main.yml create mode 100644 test/integration/targets/binary/tasks/main.yml create mode 100644 test/integration/targets/binary/templates/b64_latin1_template.j2 create mode 100644 test/integration/targets/binary/templates/b64_utf8_template.j2 create mode 100644 test/integration/targets/binary/templates/from_playbook_template.j2 create mode 100644 test/integration/targets/binary/vars/main.yml (limited to 'test/integration/targets/binary') diff --git a/test/integration/targets/binary/aliases b/test/integration/targets/binary/aliases new file mode 100644 index 0000000..6452e6d --- /dev/null +++ b/test/integration/targets/binary/aliases @@ -0,0 +1,2 @@ +shippable/posix/group2 +context/target diff --git a/test/integration/targets/binary/files/b64_latin1 b/test/integration/targets/binary/files/b64_latin1 new file mode 100644 index 0000000..c7fbdeb --- /dev/null +++ b/test/integration/targets/binary/files/b64_latin1 @@ -0,0 +1 @@ +Café Eñe diff --git a/test/integration/targets/binary/files/b64_utf8 b/test/integration/targets/binary/files/b64_utf8 new file mode 100644 index 0000000..c7fbdeb --- /dev/null +++ b/test/integration/targets/binary/files/b64_utf8 @@ -0,0 +1 @@ +Café Eñe diff --git a/test/integration/targets/binary/files/from_playbook b/test/integration/targets/binary/files/from_playbook new file mode 100644 index 0000000..c7fbdeb --- /dev/null +++ b/test/integration/targets/binary/files/from_playbook @@ -0,0 +1 @@ +Café Eñe diff --git a/test/integration/targets/binary/meta/main.yml b/test/integration/targets/binary/meta/main.yml new file mode 100644 index 0000000..cb6005d --- /dev/null +++ b/test/integration/targets/binary/meta/main.yml @@ -0,0 +1,3 @@ +dependencies: + - prepare_tests + - setup_remote_tmp_dir diff --git a/test/integration/targets/binary/tasks/main.yml b/test/integration/targets/binary/tasks/main.yml new file mode 100644 index 0000000..2d417b5 --- /dev/null +++ b/test/integration/targets/binary/tasks/main.yml @@ -0,0 +1,131 @@ +--- +# 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. + +# In v1: The following line will traceback if it's the first task in the role. +# Does not traceback if it's the second or third etc task. +- debug: msg="{{ utf8_simple_accents|b64decode}}" + +# Expected values of the written files +- name: get checksums that we expect later files to have + copy: + src: from_playbook + dest: "{{ remote_tmp_dir }}" + +- copy: + src: b64_utf8 + dest: "{{ remote_tmp_dir }}" + +- copy: + src: b64_latin1 + dest: "{{ remote_tmp_dir }}" + +- stat: + path: "{{ remote_tmp_dir }}/from_playbook" + register: from_playbook + +- stat: + path: "{{ remote_tmp_dir }}/b64_utf8" + register: b64_utf8 + +- stat: + path: "{{ remote_tmp_dir }}/b64_latin1" + register: b64_latin1 + +# Tests themselves +- name: copy with utf-8 content in a playbook + copy: + content: "{{ simple_accents }}\n" + dest: "{{ remote_tmp_dir }}/from_playbook.txt" + +- name: Check that copying utf-8 content matches + stat: + path: "{{ remote_tmp_dir }}/from_playbook.txt" + register: results + +- assert: + that: + - 'results.stat.checksum == from_playbook.stat.checksum' + +- name: copy with utf8 in a base64 encoded string + copy: + content: "{{ utf8_simple_accents|b64decode }}\n" + dest: "{{ remote_tmp_dir }}/b64_utf8.txt" + +- name: Check that utf8 in a base64 string matches + stat: + path: "{{ remote_tmp_dir }}/b64_utf8.txt" + register: results + +- assert: + that: + - 'results.stat.checksum == b64_utf8.stat.checksum' + +- name: copy with latin1 in a base64 encoded string + copy: + content: "{{ latin1_simple_accents|b64decode }}\n" + dest: "{{ remote_tmp_dir }}/b64_latin1.txt" + +- name: Check that latin1 in a base64 string matches + stat: + path: "{{ remote_tmp_dir }}/b64_latin1.txt" + register: results + +- assert: + that: + - 'results.stat.checksum == b64_latin1.stat.checksum' + # This one depends on being able to pass binary data through + # Might be a while before we find a solution for this + ignore_errors: True + +- name: Template with a unicode string from the playbook + template: + src: "from_playbook_template.j2" + dest: "{{ remote_tmp_dir }}/from_playbook_template.txt" + +- name: Check that writing a template from a playbook var matches + stat: + path: "{{ remote_tmp_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: "{{ remote_tmp_dir }}/b64_utf8_template.txt" + +- name: Check that writing a template from a base64 encoded utf8 string matches + stat: + path: "{{ remote_tmp_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: "{{ remote_tmp_dir }}/b64_latin1_template.txt" + +- name: Check that writing a template from a base64 encoded latin1 string matches + stat: + path: "{{ remote_tmp_dir }}/b64_latin1_template.txt" + register: results + +- assert: + that: + - 'results.stat.checksum == b64_latin1.stat.checksum' + # This one depends on being able to pass binary data through + # Might be a while before we find a solution for this + ignore_errors: True + +# 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/targets/binary/templates/b64_latin1_template.j2 b/test/integration/targets/binary/templates/b64_latin1_template.j2 new file mode 100644 index 0000000..ee2fc1b --- /dev/null +++ b/test/integration/targets/binary/templates/b64_latin1_template.j2 @@ -0,0 +1 @@ +{{ latin1_simple_accents|b64decode }} diff --git a/test/integration/targets/binary/templates/b64_utf8_template.j2 b/test/integration/targets/binary/templates/b64_utf8_template.j2 new file mode 100644 index 0000000..9fd3ed4 --- /dev/null +++ b/test/integration/targets/binary/templates/b64_utf8_template.j2 @@ -0,0 +1 @@ +{{ utf8_simple_accents|b64decode }} diff --git a/test/integration/targets/binary/templates/from_playbook_template.j2 b/test/integration/targets/binary/templates/from_playbook_template.j2 new file mode 100644 index 0000000..3be6dd4 --- /dev/null +++ b/test/integration/targets/binary/templates/from_playbook_template.j2 @@ -0,0 +1 @@ +{{ simple_accents }} diff --git a/test/integration/targets/binary/vars/main.yml b/test/integration/targets/binary/vars/main.yml new file mode 100644 index 0000000..f6d4023 --- /dev/null +++ b/test/integration/targets/binary/vars/main.yml @@ -0,0 +1,3 @@ +simple_accents: 'Café Eñe' +utf8_simple_accents: 'Q2Fmw6kgRcOxZQ==' +latin1_simple_accents: 'Q2Fm6SBF8WU=' -- cgit v1.2.3