summaryrefslogtreecommitdiff
path: root/tests/unittests
diff options
context:
space:
mode:
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