示例#1
0
    def test_feed_information_response_deprecated(self):
        # Test nested-class forms:
        #   FeedInformationResponse.FeedInformation
        #   FeedInformationResponse.FeedInformation.PushMethod
        #   FeedInformationResponse.FeedInformation.PollingServiceInstance
        #   FeedInformationResponse.FeedInformation.SubscriptionMethod

        push_method1 = tm10.FeedInformationResponse.FeedInformation.PushMethod(
            push_protocol=t.VID_TAXII_HTTP_10,
            push_message_bindings=[t.VID_TAXII_XML_10])

        polling_service1 = tm10.FeedInformationResponse.FeedInformation.PollingServiceInstance(
            poll_protocol=t.VID_TAXII_HTTP_10,
            poll_address='http://example.com/PollService/',
            poll_message_bindings=[t.VID_TAXII_XML_10])

        subscription_service1 = tm10.FeedInformationResponse.FeedInformation.SubscriptionMethod(
            subscription_protocol=t.VID_TAXII_HTTP_10,
            subscription_address='http://example.com/SubsService/',
            subscription_message_bindings=[t.VID_TAXII_XML_10])

        feed1 = tm10.FeedInformationResponse.FeedInformation(
            feed_name='Feed1',
            feed_description='Description of a feed',
            supported_contents=[t.CB_STIX_XML_10],
            push_methods=[push_method1],
            polling_service_instances=[polling_service1],
            subscription_methods=[subscription_service1])

        feed_information_response1 = tm10.FeedInformationResponse(
            message_id=tm10.generate_message_id(),
            in_response_to=tm10.generate_message_id(),
            feed_informations=[feed1])

        round_trip_message(feed_information_response1)
示例#2
0
    def test_feed_information_response1(self):
        push_method1 = tm10.PushMethod(
            push_protocol=t.VID_TAXII_HTTP_10,  # Required
            push_message_bindings=[t.VID_TAXII_XML_10])  # Required

        polling_service1 = tm10.PollingServiceInstance(
            poll_protocol=t.VID_TAXII_HTTP_10,  # Required
            poll_address='http://example.com/PollService/',  # Required
            poll_message_bindings=[t.VID_TAXII_XML_10])  # Required

        subscription_service1 = tm10.SubscriptionMethod(
            subscription_protocol=t.VID_TAXII_HTTP_10,  # Required
            subscription_address='http://example.com/SubsService/',  # Required
            subscription_message_bindings=[t.VID_TAXII_XML_10])  # Required

        feed1 = tm10.FeedInformation(
            feed_name='Feed1',  # Required
            feed_description='Description of a feed',  # Required
            supported_contents=[t.CB_STIX_XML_10],  # Required. List of supported content binding IDs
            available=True,  # Optional. Defaults to None (aka Unknown)
            push_methods=[push_method1],  # Required if there are no polling_services. Optional otherwise
            polling_service_instances=[polling_service1],  # Required if there are no push_methods. Optional otherwise.
            subscription_methods=[subscription_service1])  # Optional

        feed_information_response1 = tm10.FeedInformationResponse(
            message_id=tm10.generate_message_id(),  # Required
            in_response_to=tm10.generate_message_id(),  # Required. This should be the ID of the corresponding request
            feed_informations=[feed1])  # Optional

        round_trip_message(feed_information_response1)
    def handle_message(cls, service, request):

        response = tm10.FeedInformationResponse(
            message_id=cls.generate_id(), in_response_to=request.message_id)

        for collection in service.advertised_collections:
            feed = collection_to_feedcollection_information(service,
                                                            collection,
                                                            version=10)
            response.feed_informations.append(feed)

        return response