summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorScott Moser <smoser@ubuntu.com>2012-11-12 12:26:49 -0500
committerScott Moser <smoser@ubuntu.com>2012-11-12 12:26:49 -0500
commit7ba753720cd95bfca61c82445cf9c7882fe5d6f1 (patch)
tree1a39ce4eaa65be910c10b0155f5d4c463e6a4027 /tests
parent8730e143ec07372107d794abe9f4857ead6d4718 (diff)
downloadvyos-cloud-init-7ba753720cd95bfca61c82445cf9c7882fe5d6f1.tar.gz
vyos-cloud-init-7ba753720cd95bfca61c82445cf9c7882fe5d6f1.zip
config-drive-v2: support public keys
This does a couple things: * separates out the 'normalize_public_keys' from the DataSource's get_public_ssh_keys * uses that from config-drive datasource * supports config drive v1 or v2 public-keys * adds a test. LP: #1077700
Diffstat (limited to 'tests')
-rw-r--r--tests/unittests/test_datasource/test_configdrive.py26
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/unittests/test_datasource/test_configdrive.py b/tests/unittests/test_datasource/test_configdrive.py
index 00379e03..aa5b98ed 100644
--- a/tests/unittests/test_datasource/test_configdrive.py
+++ b/tests/unittests/test_datasource/test_configdrive.py
@@ -288,6 +288,32 @@ class TestConfigDriveDataSource(MockerTestCase):
finally:
util.find_devs_with = orig_find_devs_with
+ def test_pubkeys_v2(self):
+ """Verify that public-keys work in config-drive-v2."""
+ populate_dir(self.tmp, CFG_DRIVE_FILES_V2)
+ myds = cfg_ds_from_dir(self.tmp)
+ self.assertEqual(myds.get_public_ssh_keys(),
+ [OSTACK_META['public_keys']['mykey']])
+
+
+def cfg_ds_from_dir(seed_d):
+ found = ds.read_config_drive_dir(seed_d)
+ cfg_ds = ds.DataSourceConfigDrive(settings.CFG_BUILTIN, None,
+ helpers.Paths({}))
+ populate_ds_from_read_config(cfg_ds, seed_d, found)
+ return cfg_ds
+
+
+def populate_ds_from_read_config(cfg_ds, source, results):
+ """Patch the DataSourceConfigDrive from the results of
+ read_config_drive_dir hopefully in line with what it would have
+ if cfg_ds.get_data had been successfully called"""
+ cfg_ds.source = source
+ cfg_ds.metadata = results.get('metadata')
+ cfg_ds.ec2_metadata = results.get('ec2-metadata')
+ cfg_ds.userdata_raw = results.get('userdata')
+ cfg_ds.version = results.get('cfgdrive_ver')
+
def populate_dir(seed_dir, files):
for (name, content) in files.iteritems():