summaryrefslogtreecommitdiffstats
path: root/test/integration/targets/binary/tasks/main.yml
blob: 2d417b56fb816ef6b5f7efdc70037c570c0abff7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
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}}"