diff options
author | Mike Milner <mike.milner@canonical.com> | 2012-01-12 19:28:09 +0100 |
---|---|---|
committer | Mike Milner <mike.milner@canonical.com> | 2012-01-12 19:28:09 +0100 |
commit | a717e4f8b9210374edcc9053ca6ff980cb0cefff (patch) | |
tree | c0fa6450edd6aaa01f34ae81248670dbd68b7b54 /tests | |
parent | fb0ff769bdce25497949770d392f43b2888a732b (diff) | |
download | vyos-cloud-init-a717e4f8b9210374edcc9053ca6ff980cb0cefff.tar.gz vyos-cloud-init-a717e4f8b9210374edcc9053ca6ff980cb0cefff.zip |
Add ability to rebuild CA certificate file.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/unittests/test_handler_ca_certs.py | 37 |
1 files changed, 32 insertions, 5 deletions
diff --git a/tests/unittests/test_handler_ca_certs.py b/tests/unittests/test_handler_ca_certs.py index 21eddf18..254c8727 100644 --- a/tests/unittests/test_handler_ca_certs.py +++ b/tests/unittests/test_handler_ca_certs.py @@ -1,25 +1,42 @@ from unittest import TestCase from mocker import MockerTestCase -from cloudinit.CloudConfig.cc_ca_certs import handle, write_file +from cloudinit.CloudConfig.cc_ca_certs import handle, write_file, update_ca_certs -class TestAddCaCerts(MockerTestCase): +class TestNoConfig(MockerTestCase): def setUp(self): - super(TestAddCaCerts, self).setUp() + super(TestNoConfig, self).setUp() self.name = "ca-certs" self.cloud_init = None self.log = None self.args = [] def test_no_config(self): - """Test that no certificate are written if not provided.""" + """ + Test that nothing is done if no ca-certs configuration is provided. + """ config = {"unknown-key": "value"} - mock = self.mocker.replace(write_file, passthrough=False) + self.mocker.replace(write_file, passthrough=False) + self.mocker.replace(update_ca_certs, passthrough=False) self.mocker.replay() handle(self.name, config, self.cloud_init, self.log, self.args) + +class TestAddCaCerts(MockerTestCase): + def setUp(self): + super(TestAddCaCerts, self).setUp() + self.name = "ca-certs" + self.cloud_init = None + self.log = None + self.args = [] + + # The config option is present for all these tests so + # update_ca_certs should always be called. + mock = self.mocker.replace(update_ca_certs, passthrough=False) + mock() + def test_no_trusted_list(self): """Test that no certificate are written if not provided.""" config = {"ca-certs": {}} @@ -62,3 +79,13 @@ class TestAddCaCerts(MockerTestCase): self.mocker.replay() handle(self.name, config, self.cloud_init, self.log, self.args) + +class TestUpdateCaCerts(MockerTestCase): + def test_commands(self): + mock_check_call = self.mocker.replace("subprocess.check_call", + passthrough=False) + mock_check_call(["dpkg-reconfigure", "ca-certificates"]) + mock_check_call(["update-ca-certificates"]) + self.mocker.replay() + + update_ca_certs() |