summaryrefslogtreecommitdiff
path: root/tests/unittests
diff options
context:
space:
mode:
authorChristian Ehrhardt <christian.ehrhardt@canonical.com>2016-05-10 17:14:26 +0200
committerChristian Ehrhardt <christian.ehrhardt@canonical.com>2016-05-10 17:14:26 +0200
commit66f847f4cba2215490986ffede8e03299dbd5b90 (patch)
tree5fd50f121dbd19be113ef99979a7287c0a4081e0 /tests/unittests
parent8cb8502cc1c99ec787e23504cf4e9f60c01bf0fe (diff)
downloadvyos-cloud-init-66f847f4cba2215490986ffede8e03299dbd5b90.tar.gz
vyos-cloud-init-66f847f4cba2215490986ffede8e03299dbd5b90.zip
add test_apt_source_key for sources with a keyid to import
Diffstat (limited to 'tests/unittests')
-rw-r--r--tests/unittests/test_handler/test_handler_apt_source.py32
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/unittests/test_handler/test_handler_apt_source.py b/tests/unittests/test_handler/test_handler_apt_source.py
index 22a4accf..d9942901 100644
--- a/tests/unittests/test_handler/test_handler_apt_source.py
+++ b/tests/unittests/test_handler/test_handler_apt_source.py
@@ -104,6 +104,38 @@ class TestAptSourceConfig(TestCase):
contents, flags=re.IGNORECASE))
+ def test_apt_source_key(self):
+ """ test_apt_source_key
+ Test specification of a source + key
+ """
+ params = self._get_default_params()
+ cfg = {'source': ('deb '
+ 'http://ppa.launchpad.net/'
+ 'smoser/cloud-init-test/ubuntu'
+ ' xenial main'),
+ 'keyid:': "03683F77",
+ 'filename': self.aptlistfile}
+
+ cc_apt_configure.add_sources([cfg], params)
+
+ self.assertTrue(os.path.isfile(self.aptlistfile))
+
+ # report content before making regex
+ contents = load_tfile_or_url(self.aptlistfile)
+ self.assertTrue(re.search(r"%s %s %s %s\n" %
+ ("deb",
+ ('http://ppa.launchpad.net/smoser/'
+ 'cloud-init-test/ubuntu'),
+ "xenial", "main"),
+ contents, flags=re.IGNORECASE))
+ # check if key was imported
+ try:
+ util.subp(('apt-key', 'list', '03683F77'))
+ except util.ProcessExecutionError as err:
+ print("apt-key failed. " + str(err))
+ self.assertTrue(1 == 2)
+
+
def test_apt_source_ppa(self):
""" test_apt_source_ppa
Test specification of a ppa