Container Infrastructure Management Service for OpenStack
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

58 lines
2.3 KiB

# Copyright 2015 NEC Corporation. All rights reserved.
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import mock
from magnum.conductor.handlers import ca_conductor
from magnum.tests import base
class TestSignConductor(base.TestCase):
def setUp(self):
super(TestSignConductor, self).setUp()
self.ca_handler = ca_conductor.Handler()
@mock.patch.object(ca_conductor, 'cert_manager')
def test_sign_certificate(self, mock_cert_manager):
mock_bay = mock.MagicMock()
mock_certificate = mock.MagicMock()
mock_certificate.csr = 'fake-csr'
mock_cert_manager.sign_node_certificate.return_value = 'fake-pem'
actual_cert = self.ca_handler.sign_certificate(self.context,
mock_bay, 'fake-csr', context=self.context
self.assertEqual('fake-pem', actual_cert.pem)
@mock.patch.object(ca_conductor, 'cert_manager')
def test_get_ca_certificate(self, mock_cert_manager):
mock_bay = mock.MagicMock()
mock_bay.uuid = 'bay-uuid'
mock_bay.user_id = 'user-id'
mock_bay.project_id = 'project-id'
mock_cert = mock.MagicMock()
mock_cert.get_certificate.return_value = 'fake-pem'
mock_cert_manager.get_bay_ca_certificate.return_value = mock_cert
actual_cert = self.ca_handler.get_ca_certificate(self.context,
self.assertEqual(mock_bay.uuid, actual_cert.bay_uuid)
self.assertEqual(mock_bay.user_id, actual_cert.user_id)
self.assertEqual(mock_bay.project_id, actual_cert.project_id)
self.assertEqual('fake-pem', actual_cert.pem)