def test_configure_SSL_when_SSL_enabled(self, mock_getboolean, mock_celery): """ Make sure that the Celery config has BROKER_USE_SSL properly formed if SSL enabled. """ mock_getboolean.return_value = True mock_cacert = mock.Mock() mock_keyfile = mock.Mock() mock_certfile = mock.Mock() CONFIG_OVERRIDE = { 'tasks': { 'cacert': mock_cacert, 'keyfile': mock_keyfile, 'certfile': mock_certfile, 'cert_reqs': ssl.CERT_REQUIRED } } EXPECTED_BROKER_USE_SSL = { 'ca_certs': mock_cacert, 'keyfile': mock_keyfile, 'certfile': mock_certfile, 'cert_reqs': ssl.CERT_REQUIRED, } custom_fake_get = partial(fake_get, CONFIG_OVERRIDE) with mock.patch('pulp.server.async.celery_instance.config.get', new=custom_fake_get): celery_instance.configure_SSL() mock_celery.conf.update.assert_called_once_with( BROKER_USE_SSL=EXPECTED_BROKER_USE_SSL)
def test_configure_SSL_when_SSL_enabled(self, mock_getboolean, mock_celery): """ Make sure that the Celery config has BROKER_USE_SSL properly formed if SSL enabled. """ mock_getboolean.return_value = True mock_cacert = mock.Mock() mock_keyfile = mock.Mock() mock_certfile = mock.Mock() CONFIG_OVERRIDE = { 'tasks': { 'cacert': mock_cacert, 'keyfile': mock_keyfile, 'certfile': mock_certfile, 'cert_reqs': ssl.CERT_REQUIRED} } EXPECTED_BROKER_USE_SSL = { 'ca_certs': mock_cacert, 'keyfile': mock_keyfile, 'certfile': mock_certfile, 'cert_reqs': ssl.CERT_REQUIRED, } custom_fake_get = partial(fake_get, CONFIG_OVERRIDE) with mock.patch('pulp.server.async.celery_instance.config.get', new=custom_fake_get): celery_instance.configure_SSL() mock_celery.conf.update.assert_called_once_with(BROKER_USE_SSL=EXPECTED_BROKER_USE_SSL)
def test_configure_SSL_when_SSL_disabled(self, mock_getboolean): """ Make sure that the Celery config has BROKER_USE_SSL set to False if SSL is disabled. """ mock_getboolean.return_value = False celery_instance.configure_SSL() self.assertFalse(celery_instance.celery.conf['BROKER_USE_SSL'])