summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/unittests/test_handler_ca_certs.py22
1 files changed, 10 insertions, 12 deletions
diff --git a/tests/unittests/test_handler_ca_certs.py b/tests/unittests/test_handler_ca_certs.py
index 254c8727..7c0197ed 100644
--- a/tests/unittests/test_handler_ca_certs.py
+++ b/tests/unittests/test_handler_ca_certs.py
@@ -1,7 +1,7 @@
from unittest import TestCase
from mocker import MockerTestCase
-from cloudinit.CloudConfig.cc_ca_certs import handle, write_file, update_ca_certs
+from cloudinit.CloudConfig.cc_ca_certs import handle, write_file, update_ca_certs, add_ca_certs
class TestNoConfig(MockerTestCase):
def setUp(self):
@@ -24,9 +24,9 @@ class TestNoConfig(MockerTestCase):
handle(self.name, config, self.cloud_init, self.log, self.args)
-class TestAddCaCerts(MockerTestCase):
+class TestConfig(MockerTestCase):
def setUp(self):
- super(TestAddCaCerts, self).setUp()
+ super(TestConfig, self).setUp()
self.name = "ca-certs"
self.cloud_init = None
self.log = None
@@ -46,39 +46,37 @@ class TestAddCaCerts(MockerTestCase):
handle(self.name, config, self.cloud_init, self.log, self.args)
+
+class TestAddCaCerts(MockerTestCase):
def test_no_certs_in_list(self):
"""Test that no certificate are written if not provided."""
- config = {"ca-certs": {"trusted": []}}
-
mock = self.mocker.replace(write_file, passthrough=False)
self.mocker.replay()
- handle(self.name, config, self.cloud_init, self.log, self.args)
+ add_ca_certs([])
def test_single_cert(self):
"""Test adding a single certificate to the trusted CAs"""
cert = "CERT1\nLINE2\nLINE3"
- config = {"ca-certs": {"trusted": cert}}
mock = self.mocker.replace(write_file, passthrough=False)
mock("/usr/share/ca-certificates/cloud-init-provided.crt",
cert, "root", "root", "644")
self.mocker.replay()
- handle(self.name, config, self.cloud_init, self.log, self.args)
+ add_ca_certs([cert])
def test_multiple_certs(self):
"""Test adding multiple certificate to the trusted CAs"""
certs = ["CERT1\nLINE2\nLINE3", "CERT2\nLINE2\nLINE3"]
- cert_file = "\n".join(certs)
- config = {"ca-certs": {"trusted": certs}}
+ expected_cert_file = "\n".join(certs)
mock = self.mocker.replace(write_file, passthrough=False)
mock("/usr/share/ca-certificates/cloud-init-provided.crt",
- cert_file, "root", "root", "644")
+ expected_cert_file, "root", "root", "644")
self.mocker.replay()
- handle(self.name, config, self.cloud_init, self.log, self.args)
+ add_ca_certs(certs)
class TestUpdateCaCerts(MockerTestCase):
def test_commands(self):