Merge "Don't send confirmation notification if it's not enabled"

This commit is contained in:
Jenkins 2016-11-08 07:10:21 +00:00 committed by Gerrit Code Review
commit 05acfe4830
2 changed files with 21 additions and 1 deletions

View File

@ -82,6 +82,11 @@ class NotifierDriver(object):
def send_confirm_notification(self, queue, subscription, conf,
project=None, expires=None,
api_version=None):
# NOTE(flwang): If the confirmation feature isn't enabled, just do
# nothing.
if not self.require_confirmation:
return
key = conf.signed_url.secret_key
if not key:
LOG.error(_LE("Can't send confirm notification due to the value of"

View File

@ -18,6 +18,7 @@ import uuid
import mock
from zaqar.common import urls
from zaqar.notification import notifier
from zaqar import tests as testing
@ -269,7 +270,8 @@ class NotifierTest(testing.TestBase):
'options': {}}
ctlr = mock.MagicMock()
ctlr.list = mock.Mock(return_value=subscription)
driver = notifier.NotifierDriver(subscription_controller=ctlr)
driver = notifier.NotifierDriver(subscription_controller=ctlr,
require_confirmation=True)
self.conf.signed_url.secret_key = 'test_key'
driver.send_confirm_notification('test_queue', subscription, self.conf,
str(self.project),
@ -298,3 +300,16 @@ class NotifierTest(testing.TestBase):
driver.executor.shutdown()
self.assertEqual(0, mock_request.call_count)
@mock.patch.object(urls, 'create_signed_url')
def test_require_confirmation_false(self, mock_create_signed_url):
subscription = [{'subscriber': 'http://trigger_me',
'source': 'fake_queue', 'options': {}}]
ctlr = mock.MagicMock()
driver = notifier.NotifierDriver(subscription_controller=ctlr,
require_confirmation=False)
driver.send_confirm_notification('test_queue', subscription, self.conf,
str(self.project), self.api_version)
self.assertFalse(mock_create_signed_url.called)