summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFei Long Wang <flwang@catalyst.net.nz>2016-11-02 14:59:59 +1300
committerFei Long Wang <flwang@catalyst.net.nz>2016-11-08 22:45:36 +0000
commit9d4497dbd9278739611d143d17224cc2355cfab9 (patch)
tree8e34d286d30b40a052c57155a6ad90e48d15b5c9
parentfdd7331440b5ec26c1008808e954e1103033c703 (diff)
Don't send confirmation notification if it's not enabledstable/newton
Currently even though the 'require_confirmation' option is False, Zaqar will send the confirmation notification anyway, which is breaking the backward compatibility. This patch will fix it and add a test for that. Closes-Bug: #1633222 Change-Id: I2d6363feab90ff737684d5c1d903c2c2d7abe106 (cherry picked from commit c19d0a0153a0e63d6806616092ed234431d4599d)
Notes
Notes (review): Code-Review+1: wangxiyuan <wangxiyuan@huawei.com> Code-Review+2: Fei Long Wang <flwang@catalyst.net.nz> Workflow+1: Fei Long Wang <flwang@catalyst.net.nz> Verified+2: Jenkins Submitted-by: Jenkins Submitted-at: Thu, 10 Nov 2016 02:04:52 +0000 Reviewed-on: https://review.openstack.org/395236 Project: openstack/zaqar Branch: refs/heads/stable/newton
-rw-r--r--zaqar/notification/notifier.py5
-rw-r--r--zaqar/tests/unit/notification/test_notifier.py17
2 files changed, 21 insertions, 1 deletions
diff --git a/zaqar/notification/notifier.py b/zaqar/notification/notifier.py
index de92836..4c56ef8 100644
--- a/zaqar/notification/notifier.py
+++ b/zaqar/notification/notifier.py
@@ -82,6 +82,11 @@ class NotifierDriver(object):
82 def send_confirm_notification(self, queue, subscription, conf, 82 def send_confirm_notification(self, queue, subscription, conf,
83 project=None, expires=None, 83 project=None, expires=None,
84 api_version=None): 84 api_version=None):
85 # NOTE(flwang): If the confirmation feature isn't enabled, just do
86 # nothing.
87 if not self.require_confirmation:
88 return
89
85 key = conf.signed_url.secret_key 90 key = conf.signed_url.secret_key
86 if not key: 91 if not key:
87 LOG.error(_LE("Can't send confirm notification due to the value of" 92 LOG.error(_LE("Can't send confirm notification due to the value of"
diff --git a/zaqar/tests/unit/notification/test_notifier.py b/zaqar/tests/unit/notification/test_notifier.py
index efc12f1..07933ab 100644
--- a/zaqar/tests/unit/notification/test_notifier.py
+++ b/zaqar/tests/unit/notification/test_notifier.py
@@ -18,6 +18,7 @@ import uuid
18 18
19import mock 19import mock
20 20
21from zaqar.common import urls
21from zaqar.notification import notifier 22from zaqar.notification import notifier
22from zaqar import tests as testing 23from zaqar import tests as testing
23 24
@@ -269,7 +270,8 @@ class NotifierTest(testing.TestBase):
269 'options': {}} 270 'options': {}}
270 ctlr = mock.MagicMock() 271 ctlr = mock.MagicMock()
271 ctlr.list = mock.Mock(return_value=subscription) 272 ctlr.list = mock.Mock(return_value=subscription)
272 driver = notifier.NotifierDriver(subscription_controller=ctlr) 273 driver = notifier.NotifierDriver(subscription_controller=ctlr,
274 require_confirmation=True)
273 self.conf.signed_url.secret_key = 'test_key' 275 self.conf.signed_url.secret_key = 'test_key'
274 driver.send_confirm_notification('test_queue', subscription, self.conf, 276 driver.send_confirm_notification('test_queue', subscription, self.conf,
275 str(self.project), 277 str(self.project),
@@ -298,3 +300,16 @@ class NotifierTest(testing.TestBase):
298 driver.executor.shutdown() 300 driver.executor.shutdown()
299 301
300 self.assertEqual(0, mock_request.call_count) 302 self.assertEqual(0, mock_request.call_count)
303
304 @mock.patch.object(urls, 'create_signed_url')
305 def test_require_confirmation_false(self, mock_create_signed_url):
306 subscription = [{'subscriber': 'http://trigger_me',
307 'source': 'fake_queue', 'options': {}}]
308 ctlr = mock.MagicMock()
309 driver = notifier.NotifierDriver(subscription_controller=ctlr,
310 require_confirmation=False)
311
312 driver.send_confirm_notification('test_queue', subscription, self.conf,
313 str(self.project), self.api_version)
314
315 self.assertFalse(mock_create_signed_url.called)