From df9ac7ff75ebe4855a2c64955dc8e8dd43570315 Mon Sep 17 00:00:00 2001 From: wangxiyuan Date: Mon, 16 May 2016 15:07:55 +0800 Subject: [PATCH] Subscription Confirmation Support-1 The subscription confirmation feature will contain four patches: 1. webhook with mongoDB 2. email with mongoDB 3. webhook with redis 4. email with redis This patch is the first part of subscription confirmation feature for webhook with MongoDB. Others will be achieved in follow patches. This patch did: 1. Add v2/queue//subscription//confirm endpoint. 2. Add a new config option: "require_confirmation". 3. Add a new property "confirmed" to subscription resource for MongoDB driver. 4. Add a new policy "subscription: confirm". 5. Add a new property "message type" for notification. 6. Use the pre-signed url in confirm request. 8. Re-use POST subscription to allow re-confirm. 9. Update notification for webhook subscription with mongoDB. 10. Support unsubscrib the subscription 11. Add tests for the feature. 12. Add doc and sample. Docimpact APIimpact Change-Id: Id38d4a5b4f9303b12e22e2b5c248facda4c00143 Implements: blueprint subscription-confirmation-support --- .../tests/tempest_plugin/tests/v2/test_subscriptions.py | 9 +++++++-- .../tests/v2/test_subscriptions_negative.py | 5 +++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/zaqar/tests/tempest_plugin/tests/v2/test_subscriptions.py b/zaqar/tests/tempest_plugin/tests/v2/test_subscriptions.py index 303af38..ea42326 100644 --- a/zaqar/tests/tempest_plugin/tests/v2/test_subscriptions.py +++ b/zaqar/tests/tempest_plugin/tests/v2/test_subscriptions.py @@ -115,10 +115,15 @@ class TestSubscriptions(base.BaseV2MessagingTest): if not test.call_until_true( lambda: self.list_messages(sub_queue)[1]['messages'], 10, 1): self.fail("Couldn't get messages") - messages = self.list_messages(sub_queue) + _, body = self.list_messages(sub_queue) expected = message_body['messages'][0] expected['queue_name'] = self.queue_name - self.assertEqual(expected, messages[1]['messages'][0]['body']) + expected['Message_Type'] = 'Notification' + for message in body['messages']: + # There are two message in the queue. One is the confirm message, + # the other one is the notification. + if message['body']['Message_Type'] == 'Notification': + self.assertEqual(expected, message['body']) @classmethod def resource_cleanup(cls): diff --git a/zaqar/tests/tempest_plugin/tests/v2/test_subscriptions_negative.py b/zaqar/tests/tempest_plugin/tests/v2/test_subscriptions_negative.py index 2e623a6..1d6b097 100644 --- a/zaqar/tests/tempest_plugin/tests/v2/test_subscriptions_negative.py +++ b/zaqar/tests/tempest_plugin/tests/v2/test_subscriptions_negative.py @@ -17,6 +17,7 @@ import uuid from tempest import config from tempest.lib.common.utils import data_utils +from tempest.lib import decorators from tempest.lib import exceptions as lib_exc from tempest import test @@ -45,6 +46,10 @@ class TestSubscriptionsNegative(base.BaseV2MessagingTest): # Create Subscriptions + # TODO(wangxiyuan): Now the subscription confirmation feature only support + # mongoDB backend. Skip this test until the feature support the redis + # backend. Then rewrite it. + @decorators.skip_because(bug='1609596') @test.attr(type=['negative']) @test.idempotent_id('fe0d8ec1-1a64-4490-8869-e821b2252e74') def test_create_subscriptions_with_duplicate_subscriber(self):