diff options
author | Daniel Watkins <oddbloke@ubuntu.com> | 2020-05-21 11:16:35 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-21 11:16:35 -0400 |
commit | 98a6d9a0da82a764943c9495d7f21f3acc5ccd05 (patch) | |
tree | e3c08b390637f8a7b86d9ff9ad05bf0201af79b0 /cloudinit/config/tests | |
parent | de9c02a4c09d603bdfe5d23478e6c050223d79b6 (diff) | |
download | vyos-cloud-init-98a6d9a0da82a764943c9495d7f21f3acc5ccd05.tar.gz vyos-cloud-init-98a6d9a0da82a764943c9495d7f21f3acc5ccd05.zip |
cc_snap: validate that assertions property values are strings (#370)
And add an example of providing a list of assertions.
Diffstat (limited to 'cloudinit/config/tests')
-rw-r--r-- | cloudinit/config/tests/test_snap.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/cloudinit/config/tests/test_snap.py b/cloudinit/config/tests/test_snap.py index 2be30186..95270fa0 100644 --- a/cloudinit/config/tests/test_snap.py +++ b/cloudinit/config/tests/test_snap.py @@ -342,6 +342,20 @@ class TestSchema(CiTestCase, SchemaTestCaseMixin): " of the given schemas\n", self.logs.getvalue()) + @mock.patch('cloudinit.config.cc_snap.run_commands') + def test_schema_when_assertions_values_are_invalid_type(self, _): + """Warnings when snap:assertions values are invalid type (e.g. int)""" + validate_cloudconfig_schema( + {'snap': {'assertions': [123]}}, schema) + validate_cloudconfig_schema( + {'snap': {'assertions': {'01': 123}}}, schema) + self.assertEqual( + "WARNING: Invalid config:\n" + "snap.assertions.0: 123 is not of type 'string'\n" + "WARNING: Invalid config:\n" + "snap.assertions.01: 123 is not of type 'string'\n", + self.logs.getvalue()) + @mock.patch('cloudinit.config.cc_snap.add_assertions') def test_warn_schema_assertions_is_not_list_or_dict(self, _): """Warn when snap:assertions config is not a list or dict.""" |