110
110
self.assertEquals('keystone_provided_ca',
113
def test_install_ca_cert(self):
113
@patch.object(apache_utils.os.path, 'isfile')
114
def test_retrieve_ca_cert(self, _isfile):
115
_isfile.return_value = True
116
with patch_open() as (_open, _file):
117
_file.read.return_value = cert
119
apache_utils.retrieve_ca_cert('mycertfile'),
121
_open.assert_called_once_with('mycertfile', 'r')
123
@patch.object(apache_utils.os.path, 'isfile')
124
def test_retrieve_ca_cert_no_file(self, _isfile):
125
_isfile.return_value = False
126
with patch_open() as (_open, _file):
128
apache_utils.retrieve_ca_cert('mycertfile'),
130
self.assertFalse(_open.called)
132
@patch.object(apache_utils, 'retrieve_ca_cert')
133
def test_install_ca_cert_new_cert(self, _retrieve_ca_cert):
134
_retrieve_ca_cert.return_value = None
114
135
with patch_open() as (_open, _file):
115
136
apache_utils.install_ca_cert(cert)
116
_open.assert_called_with('/usr/local/share/ca-certificates/keystone_juju_ca_cert.crt', 'w')
137
_open.assert_called_once_with(
138
'/usr/local/share/ca-certificates/keystone_juju_ca_cert.crt',
117
140
_file.write.assert_called_with(cert)
118
self.subprocess.check_call.assert_called_with(['update-ca-certificates', '--fresh'])
141
self.subprocess.check_call.assert_called_with(
142
['update-ca-certificates', '--fresh'])
144
@patch.object(apache_utils, 'retrieve_ca_cert')
145
def test_install_ca_cert_old_cert(self, _retrieve_ca_cert):
146
_retrieve_ca_cert.return_value = cert
147
with patch_open() as (_open, _file):
148
apache_utils.install_ca_cert(cert)
149
self.assertFalse(_open.called)
150
self.assertFalse(_file.called)
151
self.assertFalse(self.subprocess.check_call.called)