diff options
author | James Falcon <therealfalcon@gmail.com> | 2021-08-20 11:02:57 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-20 11:02:57 -0500 |
commit | 94679e178613ab5b12327829ca54855ac5b1c1c0 (patch) | |
tree | 280d81922b0d905926ff4f2af264b14d1664eda8 /tests/integration_tests/modules/test_combined.py | |
parent | 776bd36385b3bd5c796479983afd2c9492cbdbe4 (diff) | |
download | vyos-cloud-init-94679e178613ab5b12327829ca54855ac5b1c1c0.tar.gz vyos-cloud-init-94679e178613ab5b12327829ca54855ac5b1c1c0.zip |
Add integration test for sensitive jinja substitution (#986)
Ensure jinja templates work for both instance-data.json and
instance-data-sensitive.json. Test for LP: #1931392
Also removed test_runcmd.py as it's made redundant by this change.
Diffstat (limited to 'tests/integration_tests/modules/test_combined.py')
-rw-r--r-- | tests/integration_tests/modules/test_combined.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/integration_tests/modules/test_combined.py b/tests/integration_tests/modules/test_combined.py index 97b59558..27f3c074 100644 --- a/tests/integration_tests/modules/test_combined.py +++ b/tests/integration_tests/modules/test_combined.py @@ -15,6 +15,7 @@ from tests.integration_tests.instances import IntegrationInstance from tests.integration_tests.util import verify_ordered_items_in_text USER_DATA = """\ +## template: jinja #cloud-config apt: primary: @@ -31,6 +32,9 @@ locale: en_GB.UTF-8 locale_configfile: /etc/default/locale ntp: servers: ['ntp.ubuntu.com'] +runcmd: + - echo {{ds.meta_data.local_hostname}} > /var/tmp/runcmd_output + - echo {{merged_cfg.def_log_file}} >> /var/tmp/runcmd_output """ @@ -92,6 +96,22 @@ class TestCombined: 'en_US.UTF-8' ], locale_gen) + def test_runcmd_with_variable_substitution( + self, class_client: IntegrationInstance + ): + """Test runcmd, while including jinja substitution. + + Ensure we can also substitue variables from instance-data-sensitive + LP: #1931392 + """ + client = class_client + expected = [ + client.execute('hostname').stdout.strip(), + '/var/log/cloud-init.log', + ] + output = client.read_from_file('/var/tmp/runcmd_output') + verify_ordered_items_in_text(expected, output) + def test_no_problems(self, class_client: IntegrationInstance): """Test no errors, warnings, or tracebacks""" client = class_client |