summaryrefslogtreecommitdiff
path: root/tests/unittests/test_datasource/test_azure.py
diff options
context:
space:
mode:
authorScott Moser <smoser@ubuntu.com>2015-02-24 11:58:22 -0500
committerScott Moser <smoser@ubuntu.com>2015-02-24 11:58:22 -0500
commitf1ee9275a504c20153b795923b1f51d3005d745c (patch)
tree626ec9f03f7bfab4c8107a46ab0680420eb6b8e9 /tests/unittests/test_datasource/test_azure.py
parent43a8d82141c5abcdf5ca546fd5a8ebc95cb3cbaf (diff)
downloadvyos-cloud-init-f1ee9275a504c20153b795923b1f51d3005d745c.tar.gz
vyos-cloud-init-f1ee9275a504c20153b795923b1f51d3005d745c.zip
use util.decode_binary rather than str, add tests.
just seems to make more sense to decode here. Add a test showing the previous failure (testBytesInPayload) And one that should pass (testStringInPayload) Also, add a test for unencoded content in the ovf xml (test_userdata_plain) And explicitly set encoding on another test (test_userdata_found).
Diffstat (limited to 'tests/unittests/test_datasource/test_azure.py')
-rw-r--r--tests/unittests/test_datasource/test_azure.py14
1 files changed, 12 insertions, 2 deletions
diff --git a/tests/unittests/test_datasource/test_azure.py b/tests/unittests/test_datasource/test_azure.py
index 38d70fcd..8112c69b 100644
--- a/tests/unittests/test_datasource/test_azure.py
+++ b/tests/unittests/test_datasource/test_azure.py
@@ -1,5 +1,5 @@
from cloudinit import helpers
-from cloudinit.util import b64e, load_file
+from cloudinit.util import b64e, decode_binary, load_file
from cloudinit.sources import DataSourceAzure
from ..helpers import TestCase, populate_dir
@@ -231,9 +231,19 @@ class TestAzureDataSource(TestCase):
self.assertEqual(defuser['passwd'],
crypt.crypt(odata['UserPassword'], defuser['passwd'][0:pos]))
+ def test_userdata_plain(self):
+ mydata = "FOOBAR"
+ odata = {'UserData': {'text': mydata, 'encoding': 'plain'}}
+ data = {'ovfcontent': construct_valid_ovf_env(data=odata)}
+
+ dsrc = self._get_ds(data)
+ ret = dsrc.get_data()
+ self.assertTrue(ret)
+ self.assertEqual(decode_binary(dsrc.userdata_raw), mydata)
+
def test_userdata_found(self):
mydata = "FOOBAR"
- odata = {'UserData': b64e(mydata)}
+ odata = {'UserData': {'text': b64e(mydata), 'encoding': 'base64'}}
data = {'ovfcontent': construct_valid_ovf_env(data=odata)}
dsrc = self._get_ds(data)