diff options
author | Kiril Vladimiroff <kiril.vladimiroff@cloudsigma.com> | 2014-02-19 10:45:53 +0200 |
---|---|---|
committer | Kiril Vladimiroff <kiril.vladimiroff@cloudsigma.com> | 2014-02-19 10:45:53 +0200 |
commit | d1e26fc118cdb641829fbe6b838ef46d4ab1f113 (patch) | |
tree | 9b0b43b9c43e5e69540628d60189a18df01ed536 /tests | |
parent | 5e5c8051fb2b3bd7c39e46fb090b2df282779ea1 (diff) | |
download | vyos-cloud-init-d1e26fc118cdb641829fbe6b838ef46d4ab1f113.tar.gz vyos-cloud-init-d1e26fc118cdb641829fbe6b838ef46d4ab1f113.zip |
Read encoded with base64 user data
This allows users of CloudSigma's VM to encode their user data with base64.
In order to do that thet have to add the ``cloudinit-user-data`` field to
the ``base64_fields``. The latter is a comma-separated field with
all the meta fields whit base64 encoded values.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/unittests/test_datasource/test_cloudsigma.py | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/tests/unittests/test_datasource/test_cloudsigma.py b/tests/unittests/test_datasource/test_cloudsigma.py index 3245aba1..adbb4afb 100644 --- a/tests/unittests/test_datasource/test_cloudsigma.py +++ b/tests/unittests/test_datasource/test_cloudsigma.py @@ -1,4 +1,5 @@ # coding: utf-8 +import copy from unittest import TestCase from cloudinit.cs_utils import Cepko @@ -24,7 +25,8 @@ SERVER_CONTEXT = { class CepkoMock(Cepko): - result = SERVER_CONTEXT + def __init__(self, mocked_context): + self.result = mocked_context def all(self): return self @@ -33,7 +35,7 @@ class CepkoMock(Cepko): class DataSourceCloudSigmaTest(TestCase): def setUp(self): self.datasource = DataSourceCloudSigma.DataSourceCloudSigma("", "", "") - self.datasource.cepko = CepkoMock() + self.datasource.cepko = CepkoMock(SERVER_CONTEXT) self.datasource.get_data() def test_get_hostname(self): @@ -57,3 +59,12 @@ class DataSourceCloudSigmaTest(TestCase): def test_user_data(self): self.assertEqual(self.datasource.userdata_raw, SERVER_CONTEXT['meta']['cloudinit-user-data']) + + def test_encoded_user_data(self): + encoded_context = copy.deepcopy(SERVER_CONTEXT) + encoded_context['meta']['base64_fields'] = 'cloudinit-user-data' + encoded_context['meta']['cloudinit-user-data'] = 'aGkgd29ybGQK' + self.datasource.cepko = CepkoMock(encoded_context) + self.datasource.get_data() + + self.assertEqual(self.datasource.userdata_raw, b'hi world\n') |