summaryrefslogtreecommitdiff
path: root/tests/unittests/test_data.py
diff options
context:
space:
mode:
authorScott Moser <smoser@ubuntu.com>2016-06-21 16:27:02 -0400
committerScott Moser <smoser@ubuntu.com>2016-06-21 16:27:02 -0400
commit145256f964388423965bc77c2a780a89ed62dc2e (patch)
treee2383b7269204172ca57f835f92bb3820654451a /tests/unittests/test_data.py
parenta919f6e6ee3bfaf489411a4452fc708061b1239f (diff)
downloadvyos-cloud-init-145256f964388423965bc77c2a780a89ed62dc2e.tar.gz
vyos-cloud-init-145256f964388423965bc77c2a780a89ed62dc2e.zip
user_data: fix error when user-data is not utf-8 decodable
when user-data was not decodable, cloud-init would raise exception. LP: #1532072
Diffstat (limited to 'tests/unittests/test_data.py')
-rw-r--r--tests/unittests/test_data.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/unittests/test_data.py b/tests/unittests/test_data.py
index 1923e2af..17951117 100644
--- a/tests/unittests/test_data.py
+++ b/tests/unittests/test_data.py
@@ -557,3 +557,15 @@ class TestUDProcess(helpers.ResourceUsingTestCase):
ud_proc = ud.UserDataProcessor(self.getCloudPaths())
message = ud_proc.process(msg)
self.assertTrue(count_messages(message) == 1)
+
+
+class TestConvert(helpers.TestCase):
+ def test_handles_binary(self):
+ blob = b'\x32\x99'
+ msg = ud.convert_string(blob)
+ self.assertEqual(blob, msg.get_payload(decode=True))
+
+ def test_handle_headers(self):
+ text = "hi mom"
+ msg = ud.convert_string(text)
+ self.assertEqual(text, msg.get_payload(decode=False))