Fix wrong value of require_confirmation

Currently, Zaqar's notifier driver will be initialized without
any parameter when creating the subscription controller. As a
result, default value 'False' will be used instead of getting
the correct value from conf. This patch will fix this by getting
the option from conf.

Closes-Bug: #1655812

Change-Id: I31ac8c3d374b3ea38d035f1012571e6c49a18b87
This commit is contained in:
Fei Long Wang 2017-01-12 16:28:54 +13:00
parent 73eab55b3b
commit 8e32ee254a
2 changed files with 7 additions and 2 deletions

View File

@ -83,8 +83,12 @@ class NotifierDriver(object):
project=None, expires=None,
api_version=None):
# NOTE(flwang): If the confirmation feature isn't enabled, just do
# nothing.
if not self.require_confirmation:
# nothing. Here we're getting the require_confirmation from conf
# object instead of using self.require_confirmation, because the
# variable from self object really depends on the kwargs when
# initializing the NotifierDriver object. See bug 1655812 for more
# information.
if not conf.notification.require_confirmation:
return
key = conf.signed_url.secret_key

View File

@ -264,6 +264,7 @@ class NotifierTest(testing.TestBase):
@mock.patch('requests.post')
def test_send_confirm_notification(self, mock_request):
self.conf.notification.require_confirmation = True
subscription = {'id': '5760c9fb3990b42e8b7c20bd',
'subscriber': 'http://trigger_me',
'source': 'fake_queue',