summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMartin Krizek <martin.krizek@gmail.com>2020-05-06 06:02:20 +0200
committerGitHub <noreply@github.com>2020-05-05 21:02:20 -0700
commit70b4ce5efdff05bdfd6cc520260a6af974a3cf61 (patch)
treefa17d847dc4d3b27151a63af44b19043f78739f8 /test
parent4f909589c22d5b8bb3de0dbaa91087d79ef100ea (diff)
downloadansible-70b4ce5efdff05bdfd6cc520260a6af974a3cf61.tar.gz
2.9: native types: literal_eval all the things (#68938) (#69044)
* native types: literal_eval all the things (#68938) With https://github.com/pallets/jinja/pull/1190 merged our short-circuit is no longer valid (has it ever been?) as now data like ' True ' may go through our ansible_native_concat function as opposed to going through intermediate call to Jinja2's native_concat before. Now we need to always send data through literal_eval to ensure native types are returned. (cherry picked from commit acdc9eb76d23e25ed8b1c7fc4fe8e4f9fd6f49fd) * Fix tests
Diffstat (limited to 'test')
-rwxr-xr-xtest/integration/targets/inventory_aws_conformance/runme.sh4
-rw-r--r--test/integration/targets/jinja2_native_types/filter_plugins/native_plugins.py8
-rw-r--r--test/integration/targets/jinja2_native_types/test_casting.yml6
-rw-r--r--test/integration/targets/jinja2_native_types/test_concatentation.yml2
-rw-r--r--test/sanity/ignore.txt2
5 files changed, 6 insertions, 16 deletions
diff --git a/test/integration/targets/inventory_aws_conformance/runme.sh b/test/integration/targets/inventory_aws_conformance/runme.sh
index 0577295589..4495cc826e 100755
--- a/test/integration/targets/inventory_aws_conformance/runme.sh
+++ b/test/integration/targets/inventory_aws_conformance/runme.sh
@@ -83,7 +83,7 @@ compose:
ec2_kernel: kernel_id | default("")
ec2_monitored: monitoring['state'] in ['enabled', 'pending']
ec2_monitoring_state: monitoring['state']
- ec2_account_id: owner_id
+ ec2_account_id: owner_id | string | regex_replace('^(.*)$', '"\\1"') # work around the fact that the string filter is not reliable on native jinja
ec2_placement: placement['availability_zone']
ec2_ramdisk: ramdisk_id | default("")
ec2_reason: state_transition_reason
@@ -95,7 +95,7 @@ compose:
ec2_sourceDestCheck: source_dest_check | lower | string # butchered snake_case case not a typo.
# vars that just need ec2_ prefix
- ec2_ami_launch_index: ami_launch_index | string
+ ec2_ami_launch_index: ami_launch_index | string | regex_replace('^(.*)$', '"\\1"') # see ec2_account_id for why this needs to be quoted
ec2_architecture: architecture
ec2_client_token: client_token
ec2_ebs_optimized: ebs_optimized
diff --git a/test/integration/targets/jinja2_native_types/filter_plugins/native_plugins.py b/test/integration/targets/jinja2_native_types/filter_plugins/native_plugins.py
deleted file mode 100644
index 24c716c422..0000000000
--- a/test/integration/targets/jinja2_native_types/filter_plugins/native_plugins.py
+++ /dev/null
@@ -1,8 +0,0 @@
-from ansible.module_utils._text import to_text
-
-
-class FilterModule(object):
- def filters(self):
- return {
- 'to_text': to_text,
- }
diff --git a/test/integration/targets/jinja2_native_types/test_casting.yml b/test/integration/targets/jinja2_native_types/test_casting.yml
index 5b4fe3ac0e..e66489ff5b 100644
--- a/test/integration/targets/jinja2_native_types/test_casting.yml
+++ b/test/integration/targets/jinja2_native_types/test_casting.yml
@@ -1,9 +1,9 @@
- name: cast things to other things
set_fact:
- int_to_str: "{{ i_two|to_text }}"
+ int_to_str: "'{{ i_two }}'"
str_to_int: "{{ s_two|int }}"
- dict_to_str: "{{ dict_one|to_text }}"
- list_to_str: "{{ list_one|to_text }}"
+ dict_to_str: "'{{ dict_one }}'"
+ list_to_str: "'{{ list_one }}'"
int_to_bool: "{{ i_one|bool }}"
str_true_to_bool: "{{ s_true|bool }}"
str_false_to_bool: "{{ s_false|bool }}"
diff --git a/test/integration/targets/jinja2_native_types/test_concatentation.yml b/test/integration/targets/jinja2_native_types/test_concatentation.yml
index 478182ab45..8a8077b669 100644
--- a/test/integration/targets/jinja2_native_types/test_concatentation.yml
+++ b/test/integration/targets/jinja2_native_types/test_concatentation.yml
@@ -18,7 +18,7 @@
- name: concatenate int and string
set_fact:
- string_sum: "{{ [(i_one|to_text), s_two]|join('') }}"
+ string_sum: "'{{ [i_one, s_two]|join('') }}'"
- assert:
that:
diff --git a/test/sanity/ignore.txt b/test/sanity/ignore.txt
index 82e38328e0..eb0ae20f93 100644
--- a/test/sanity/ignore.txt
+++ b/test/sanity/ignore.txt
@@ -5974,8 +5974,6 @@ test/integration/targets/inventory_kubevirt_conformance/inventory_diff.py future
test/integration/targets/inventory_kubevirt_conformance/inventory_diff.py metaclass-boilerplate
test/integration/targets/inventory_kubevirt_conformance/server.py future-import-boilerplate
test/integration/targets/inventory_kubevirt_conformance/server.py metaclass-boilerplate
-test/integration/targets/jinja2_native_types/filter_plugins/native_plugins.py future-import-boilerplate
-test/integration/targets/jinja2_native_types/filter_plugins/native_plugins.py metaclass-boilerplate
test/integration/targets/lambda_policy/files/mini_http_lambda.py future-import-boilerplate
test/integration/targets/lambda_policy/files/mini_http_lambda.py metaclass-boilerplate
test/integration/targets/lookup_properties/lookup-8859-15.ini no-smart-quotes