def service_to_service_instances(service, version): service_instances = [] for binding in service.supported_protocol_bindings: address = service.get_absolute_address(binding) if version == 10: stype = service.service_type if stype == SVC_COLLECTION_MANAGEMENT: stype = SVC_FEED_MANAGEMENT instance = tm10.ServiceInstance( service_type=stype, services_version=VID_TAXII_SERVICES_10, available=service.available, protocol_binding=binding, service_address=address, message_bindings=service.supported_message_bindings, message=service.description) elif version == 11: instance = tm11.ServiceInstance( service_type=service.service_type, services_version=VID_TAXII_SERVICES_11, available=service.available, protocol_binding=binding, service_address=address, message_bindings=service.supported_message_bindings, message=service.description) service_instances.append(instance) return service_instances
def test_discovery_response(self): service_instance1 = tm10.ServiceInstance( service_type=SVC_INBOX, # Required services_version=VID_TAXII_SERVICES_10, # Required protocol_binding=VID_TAXII_HTTP_10, # Required service_address='http://example.com/inboxservice/', # Required message_bindings=[ VID_TAXII_XML_10 ], # Required, must have at least one value in the list inbox_service_accepted_content=[ CB_STIX_XML_10 ], # Optional for service_type=SVC_INBOX, prohibited otherwise # If this is absent and service_type=SVC_INBOX, # It means the inbox service accepts all content available=True, # Optional - defaults to None, which means 'Unknown' message='This is a message.') # Optional # Create the discovery response discovery_response1 = tm10.DiscoveryResponse( message_id=tm10.generate_message_id(), # Required in_response_to=tm10.generate_message_id( ), # Required. This should be the ID of the corresponding request service_instances=[service_instance1]) # Optional. round_trip_message(discovery_response1)