From 8e32ee254a7980af542d9265a253643f8edb6be4 Mon Sep 17 00:00:00 2001 From: Fei Long Wang Date: Thu, 12 Jan 2017 16:28:54 +1300 Subject: [PATCH] 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 --- zaqar/notification/notifier.py | 8 ++++++-- zaqar/tests/unit/notification/test_notifier.py | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/zaqar/notification/notifier.py b/zaqar/notification/notifier.py index 4c56ef8b7..a9ca4b940 100644 --- a/zaqar/notification/notifier.py +++ b/zaqar/notification/notifier.py @@ -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 diff --git a/zaqar/tests/unit/notification/test_notifier.py b/zaqar/tests/unit/notification/test_notifier.py index 07933ab37..d00b7ca04 100644 --- a/zaqar/tests/unit/notification/test_notifier.py +++ b/zaqar/tests/unit/notification/test_notifier.py @@ -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',