def handle_message(cls, service, request): cls.validate_request(request) collection = retrieve_collection( 10, service, request.feed_name, request.message_id) if request.subscription_id: subscription = service.get_subscription(request.subscription_id) else: subscription = None if subscription and subscription.collection_id != collection.id: raise StatusMessageException( ST_NOT_FOUND, status_details=request.feed_name, in_response_to=request.message_id) response = tm10.ManageFeedSubscriptionResponse( message_id=cls.generate_id(), in_response_to=request.message_id, feed_name=collection.name, message=service.subscription_message, ) results = ACTIONS[request.action]( service=service, request=request, collection=collection, subscription=subscription, version=10) if not isinstance(results, (list, tuple)): results = [results] polling_services = service.get_polling_services(collection) for _result in results: instance = subscription_to_subscription_instance( subscription=_result, polling_services=polling_services, version=10) response.subscription_instances.append(instance) return response
def test_manage_feed_subscription_response(self): poll_instance1 = tm10.PollInstance( poll_protocol=t.VID_TAXII_HTTP_10, # Required poll_address='http://example.com/poll', # Required poll_message_bindings=[t.VID_TAXII_XML_10]) # Required subscription_instance1 = tm10.SubscriptionInstance( subscription_id='SubsId234', # required delivery_parameters=delivery_parameters1, # Required if message is responding to a status action. Optional otherwise poll_instances=[poll_instance1]) # Required if action was polling subscription. Optional otherwise manage_feed_subscription_response1 = tm10.ManageFeedSubscriptionResponse( message_id=tm10.generate_message_id(), # Required in_response_to=tm10.generate_message_id(), # Required - Should be the ID of the corresponding request feed_name='Feed001', # Required message='This is a message', # Optional subscription_instances=[subscription_instance1]) # Required round_trip_message(manage_feed_subscription_response1)
def test_manage_feed_subscription_response_deprecated(self): # Test nested-class forms: # ManageFeedSubscriptionResponse.PollInstance # ManageFeedSubscriptionResponse.SubscriptionInstance poll = tm10.ManageFeedSubscriptionResponse.PollInstance( poll_protocol=t.VID_TAXII_HTTP_10, poll_address='http://example.com/poll', poll_message_bindings=[t.VID_TAXII_XML_10]) subscription = tm10.ManageFeedSubscriptionResponse.SubscriptionInstance( subscription_id='SubsId234', delivery_parameters=delivery_parameters1, poll_instances=[poll]) response = tm10.ManageFeedSubscriptionResponse( message_id=tm10.generate_message_id(), in_response_to=tm10.generate_message_id(), feed_name='Feed001', subscription_instances=[subscription]) round_trip_message(response)