def test_is_cert_working_with_scmb_failed_case(self, config_mock, get_map_scmb_connections, get_oneview_client, _get_ov_ca_cert_base64data): config_mock.get_authentication_mode.return_value = 'session' config_mock.get_oneview_multiple_ips.return_value = ['1.1.1.1'] config_mock.get_config.return_value = { 'ssl': { 'SSLCertFile': '/dir/cert_file.crt' }, } oneview_client = mock.MagicMock() get_oneview_client.return_value = oneview_client oneview_client.certificate_rabbitmq.get_key_pair.return_value = { 'base64SSLCertData': 'Client CERT', 'base64SSLKeyData': 'Client Key' } oneview_client.connection = 'con' _get_ov_ca_cert_base64data.return_value = "CA CERT" get_map_scmb_connections.return_value = [] scmb.init_event_service() scmb_thread = SCMB('2.2.2.2', 'cred', 'token') self.assertFalse(scmb_thread._is_cert_working_with_scmb())
def test_init_event_service_with_valid_certificate(self, _get_ov_ca_cert, get_oneview_client, config_mock, conn_param, block_conn, channel): config_mock.get_config.return_value = { 'ssl': { 'SSLCertFile': 'cert_file.crt' }, } os.makedirs(name='scmb', exist_ok=True) self.addCleanup(shutil.rmtree, 'scmb') oneview_client = mock.MagicMock() oneview_client.certificate_authority.get.return_value = "CA CERT" oneview_client.certificate_rabbitmq.generate.return_value = True get_oneview_client.return_value = oneview_client oneview_client.certificate_rabbitmq.get_key_pair.return_value = { 'base64SSLCertData': 'Client CERT', 'base64SSLKeyData': 'Client Key' } oneview_client.connection = 'con' _get_ov_ca_cert.return_value = "CA CERT" pika_mock = mock.MagicMock() pika_mock.channel.Channel = {} block_conn.return_value = pika_mock conn_param.return_value = {} channel.return_value = {} scmb.init_event_service() scmb_thread = SCMB('1.1.1.1', 'cred', 'token') scmb_thread.run() self.assertTrue(scmb_thread._has_valid_certificates()) self.assertTrue(scmb_thread._is_cert_working_with_scmb())