Loading .gitignore +2 −1 Original line number Diff line number Diff line Loading @@ -12,6 +12,7 @@ __pycache__/ *.crt *.zip *.srl *.log services/nginx/certs/sign_req_body.json services/easy_rsa/certs/pki services/easy_rsa/certs/*EasyRSA* Loading services/TS29222_CAPIF_Events_API/capif_events/core/notifications.py +4 −3 Original line number Diff line number Diff line Loading @@ -59,11 +59,11 @@ class Notifications(): # current_app.logger.debug(json.dumps(event_detail,cls=JSONEncoder)) event_detail={redis_event.get('key'):redis_event.get('information')} data = EventNotification(sub["subscription_id"], events=redis_event.get('event'), event_detail=[event_detail]) data = EventNotification(sub["subscription_id"], events=redis_event.get('event'), event_detail=event_detail) current_app.logger.debug(json.dumps(data,cls=JSONEncoder)) # self.request_post(url, data) asyncio.run(self.send(url, json.dumps(data,cls=JSONEncoder))) asyncio.run(self.send(url, json.loads(json.dumps(data,cls=JSONEncoder)))) except Exception as e: current_app.logger.error("An exception occurred ::" + str(e)) Loading @@ -76,7 +76,8 @@ class Notifications(): async def send_request(self, url, data): async with aiohttp.ClientSession() as session: timeout = aiohttp.ClientTimeout(total=10) # Establecer timeout a 10 segundos async with session.post(url, json=data, timeout=timeout) as response: headers = {'content-type': 'application/json'} async with session.post(url, json=data, timeout=timeout, headers=headers) as response: return await response.text() async def send(self, url, data): Loading services/clean_capif_docker_services.sh +2 −0 Original line number Diff line number Diff line Loading @@ -74,4 +74,6 @@ done docker network rm capif-network docker volume prune --all --force echo "Clean complete." tests/features/CAPIF Api Events/capif_events_api.robot +182 −9 Original line number Diff line number Diff line Loading @@ -5,7 +5,6 @@ Library XML Resource /opt/robot-tests/tests/resources/common/basicRequests.robot Resource ../../resources/common.resource Suite Teardown Reset Testing Environment Test Setup Reset Testing Environment Loading Loading @@ -139,13 +138,119 @@ Deletes an individual CAPIF Event Subscription with invalid SubscriptionId ... detail=User not authorized ... cause=You are not the owner of this resource Prueba JMS [Tags] jms-1 # Log "Prueba 1" # Wait For Request # Create a log entry # [Tags] capif_api_logging_service-1 # Start Mock server Check Mock Server Clean Mock Server # Register APF ${register_user_info}= Provider Default Registration # Publish one api Publish Service Api ${register_user_info} # Register INVOKER ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding ${discover_response}= Get Request Capif ... ${DISCOVER_URL}${register_user_info_invoker['api_invoker_id']} ... server=${CAPIF_HTTPS_URL} ... verify=ca.crt ... username=${INVOKER_USERNAME} ${api_ids} ${api_names}= Get Api Ids And Names From Discover Response ${discover_response} # Subscribe to events ${events_list}= Create List SERVICE_API_INVOCATION_SUCCESS SERVICE_API_INVOCATION_FAILURE ${request_body}= Create Events Subscription ... events=@{events_list} ... notificationDestination=http://192.168.0.14:9090/testing ${resp}= Post Request Capif ... /capif-events/v1/${register_user_info_invoker['api_invoker_id']}/subscriptions ... json=${request_body} ... server=${CAPIF_HTTPS_URL} ... verify=ca.crt ... username=${INVOKER_USERNAME} # Check Results Check Response Variable Type And Values ${resp} 201 EventSubscription ${subscriber_id} ${subscription_id}= Check Event Location Header ${resp} ${results}= Create List 200 400 # Create Log Entry ${request_body}= Create Log Entry ... ${register_user_info['aef_id']} ... ${register_user_info_invoker['api_invoker_id']} ... ${api_ids} ... ${api_names} ... results=${results} ${resp}= Post Request Capif ... /api-invocation-logs/v1/${register_user_info['aef_id']}/logs ... json=${request_body} ... server=${CAPIF_HTTPS_URL} ... verify=ca.crt ... username=${AEF_PROVIDER_USERNAME} # Check Results Check Response Variable Type And Values ${resp} 201 InvocationLog ${resource_url}= Check Location Header ${resp} ${LOCATION_LOGGING_RESOURCE_REGEX} Sleep 3s # Get from Mock server the EventNotification Messages sent to callback setup on event subscription. ${resp}= Get Mock Server Messages ${notification_events_on_mock_server}= Set Variable ${resp.json()} # Check if message follow EventNotification definition. Check Variable ${notification_events_on_mock_server} EventNotification # Check if mock server receive 2 events. Length Should Be ${notification_events_on_mock_server} 2 # Now we create the expected events received at notification server according to logs sent to loggin service in order to check if all are present. ${invocation_log_base}= Copy Dictionary ${request_body} deepcopy=True # Store log array because each log will be notified in one Event Notification ${invocation_log_logs}= Set Variable ${invocation_log_base['logs']} # Remove logs array from invocationLog data Remove From Dictionary ${invocation_log_base} logs Length Should Be ${invocation_log_logs} 2 # Create 2 invocationLogs from initial invocationLog present on request ${invocation_logs_1}= Copy Dictionary ${invocation_log_base} deepcopy=True ${invocation_logs_2}= Copy Dictionary ${invocation_log_base} deepcopy=True # Create a log array with only one component ${log_1}= Create List ${invocation_log_logs[0]} ${log_2}= Create List ${invocation_log_logs[1]} # Setup logs array with previously created list Set To Dictionary ${invocation_logs_1} logs=${log_1} Set To Dictionary ${invocation_logs_2} logs=${log_2} # Create event details for each log ${event_details_1}= Create dictionary invocationLogs=${invocation_logs_1} ${event_details_2}= Create dictionary invocationLogs=${invocation_logs_2} # Create Event with Event Details from invocationLog ${event_1}= Create Dictionary ... subscriptionId=${subscription_id} ... events=SERVICE_API_INVOCATION_SUCCESS ... eventDetail=${event_details_1} ${event_2}= Create Dictionary ... subscriptionId=${subscription_id} ... events=SERVICE_API_INVOCATION_FAILURE ... eventDetail=${event_details_2} # Check if created events follow EventNotification format defined by 3gpp Check Variable ${event_1} EventNotification Check Variable ${event_2} EventNotification List Should Contain Value ${notification_events_on_mock_server} ${event_1} List Should Contain Value ${notification_events_on_mock_server} ${event_2} Prueba JMS [Tags] jms-2 # Start Mock server Check Mock Server Clean Mock Server # Register APF ${register_user_info}= Provider Default Registration Loading @@ -166,7 +271,9 @@ Prueba JMS # Subscribe to events ${events_list}= Create List SERVICE_API_INVOCATION_SUCCESS SERVICE_API_INVOCATION_FAILURE ${request_body}= Create Events Subscription events=@{events_list} notificationDestination=http://192.168.0.119:9090/testing ${request_body}= Create Events Subscription ... events=@{events_list} ... notificationDestination=http://192.168.0.14:9090/testing ${resp}= Post Request Capif ... /capif-events/v1/${register_user_info_invoker['api_invoker_id']}/subscriptions ... json=${request_body} Loading @@ -178,13 +285,15 @@ Prueba JMS Check Response Variable Type And Values ${resp} 201 EventSubscription ${subscriber_id} ${subscription_id}= Check Event Location Header ${resp} ${results}= Create List 200 400 # Create Log Entry ${request_body}= Create Log Entry ... ${register_user_info['aef_id']} ... ${register_user_info_invoker['api_invoker_id']} ... ${api_ids} ... ${api_names} ... 200 ... results=${results} ${resp}= Post Request Capif ... /api-invocation-logs/v1/${register_user_info['aef_id']}/logs ... json=${request_body} Loading @@ -196,3 +305,67 @@ Prueba JMS Check Response Variable Type And Values ${resp} 201 InvocationLog ${resource_url}= Check Location Header ${resp} ${LOCATION_LOGGING_RESOURCE_REGEX} Sleep 3s # Get from Mock server the EventNotification Messages sent to callback setup on event subscription. ${resp}= Get Mock Server Messages ${notification_events_on_mock_server}= Set Variable ${resp.json()} # Check if message follow EventNotification definition. Check Variable ${notification_events_on_mock_server} EventNotification # Create check Events to ensure all notifications were received ${check_events} ${check_events_length}= Create Events From invocationLogs ... ${subscription_id} ... ${request_body} # Number of events received must be equal than events expected Length Should Be ${notification_events_on_mock_server} ${check_events_length} # Check if events received are the same than expected FOR ${event} IN @{check_events} Log ${event} List Should Contain Value ${notification_events_on_mock_server} ${event} END *** Keywords *** Create Events From invocationLogs [Arguments] ${subscription_id} ${invocation_log} ${events}= Create List # Now we create the expected events received at notification server according to logs sent to loggin service in order to check if all are present. ${invocation_log_base}= Copy Dictionary ${invocation_log} deepcopy=True # Store log array because each log will be notified in one Event Notification ${invocation_log_logs}= Copy List ${invocation_log_base['logs']} # Remove logs array from invocationLog data Remove From Dictionary ${invocation_log_base} logs FOR ${log} IN @{invocation_log_logs} Log Dictionary ${log} ${invocation_logs}= Copy Dictionary ${invocation_log_base} deepcopy=True # Get Event Enum for this result ${event_enum}= Set Variable IF ${log['result']} >= 200 and ${log['result']} < 300 ${event_enum}= Set Variable SERVICE_API_INVOCATION_SUCCESS ELSE ${event_enum}= Set Variable SERVICE_API_INVOCATION_FAILURE END # Create a log array with only one component ${log_list}= Create List ${log} # Setup logs array with previously created list Set To Dictionary ${invocation_logs} logs=${log_list} # Create event details for each log ${event_details}= Create dictionary invocationLogs=${invocation_logs} # Create Event with Event Details from invocationLog and also is appended to events array ${event}= Create Dictionary ... subscriptionId=${subscription_id} ... events=${event_enum} ... eventDetail=${event_details} Check Variable ${event} EventNotification Append To List ${events} ${event} END Log List ${events} ${events_length}= Get Length ${events} RETURN ${events} ${events_length} tests/libraries/api_logging_service/bodyRequests.py +34 −80 Original line number Diff line number Diff line def create_log_entry(aefId, apiInvokerId, apiId, apiName, result='200'): def create_log_entry(aefId, apiInvokerId, apiId, apiName, results=['200']): data = { "aefId": aefId, "apiInvokerId": apiInvokerId, "logs": [ { "apiId": apiId[0], "apiName": apiName[0], "apiVersion": "v1", "resourceName": "string", "uri": "http://resource/endpoint", "protocol": "HTTP_1_1", "operation": "GET", "result": result, "invocationTime": "2023-03-30T10:30:21.408Z", "invocationLatency": 0, "inputParameters": "string", "outputParameters": "string", "srcInterface": { "ipv4Addr": "192.168.1.1", "fqdn": "string", "port": 65535, "apiPrefix": "string", "securityMethods": [ "PSK", "string" ] }, "destInterface": { "ipv4Addr": "192.168.1.23", "fqdn": "string", "port": 65535, "apiPrefix": "string", "securityMethods": [ "PSK", "string" ] }, "fwdInterface": "string" }, { "apiId": apiId[0], "apiName": apiName[0], "apiVersion": "v2", "resourceName": "string", "uri": "http://resource/endpoint", "protocol": "HTTP_1_1", "operation": "GET", "result": result, "invocationTime": "2023-03-30T10:30:21.408Z", "invocationLatency": 0, "inputParameters": "string", "outputParameters": "string", "srcInterface": { "ipv4Addr": "192.168.1.1", "fqdn": "string", "port": 65535, "apiPrefix": "string", "securityMethods": [ "PSK", "string" ] }, "destInterface": { "ipv4Addr": "192.168.1.23", "fqdn": "string", "port": 65535, "apiPrefix": "string", "securityMethods": [ "PSK", "string" ] }, "fwdInterface": "string" } ], "logs": [], "supportedFeatures": "ffff" } if len(results) > 0: for result in results: data['logs'].append(create_log(apiId,apiName,result)) return data def create_log_entry_bad_service(aefId, apiInvokerId, result=500): Loading @@ -92,28 +24,24 @@ def create_log_entry_bad_service(aefId, apiInvokerId, result=500): "protocol": "HTTP_1_1", "operation": "GET", "result": result, "invocationTime": "2023-03-30T10:30:21.408Z", "invocationTime": "2023-03-30T10:30:21.408000+00:00", "invocationLatency": 0, "inputParameters": "string", "outputParameters": "string", "srcInterface": { "ipv4Addr": "192.168.1.1", "fqdn": "string", "port": 65535, "apiPrefix": "string", "securityMethods": [ "PSK", "string" "PKI" ] }, "destInterface": { "ipv4Addr": "192.168.1.23", "fqdn": "string", "port": 65535, "apiPrefix": "string", "securityMethods": [ "PSK", "string" "PKI" ] }, "fwdInterface": "string" Loading @@ -131,3 +59,29 @@ def get_api_ids_and_names_from_discover_response(discover_response): api_ids.append(service_api_description['apiId']) api_names.append(service_api_description['apiName']) return api_ids, api_names def create_log(apiId, apiName, result): log= { "apiId": apiId[0], "apiName": apiName[0], "apiVersion": "v1", "resourceName": "string", "uri": "http://resource/endpoint", "protocol": "HTTP_1_1", "operation": "GET", "result": result, "invocationTime": "2023-03-30T10:30:21.408000+00:00", "invocationLatency": 0, "inputParameters": "string", "outputParameters": "string", "srcInterface": { "ipv4Addr": "192.168.1.1", "port": 65535, "securityMethods": [ "PSK", "PKI" ] } } return log No newline at end of file Loading
.gitignore +2 −1 Original line number Diff line number Diff line Loading @@ -12,6 +12,7 @@ __pycache__/ *.crt *.zip *.srl *.log services/nginx/certs/sign_req_body.json services/easy_rsa/certs/pki services/easy_rsa/certs/*EasyRSA* Loading
services/TS29222_CAPIF_Events_API/capif_events/core/notifications.py +4 −3 Original line number Diff line number Diff line Loading @@ -59,11 +59,11 @@ class Notifications(): # current_app.logger.debug(json.dumps(event_detail,cls=JSONEncoder)) event_detail={redis_event.get('key'):redis_event.get('information')} data = EventNotification(sub["subscription_id"], events=redis_event.get('event'), event_detail=[event_detail]) data = EventNotification(sub["subscription_id"], events=redis_event.get('event'), event_detail=event_detail) current_app.logger.debug(json.dumps(data,cls=JSONEncoder)) # self.request_post(url, data) asyncio.run(self.send(url, json.dumps(data,cls=JSONEncoder))) asyncio.run(self.send(url, json.loads(json.dumps(data,cls=JSONEncoder)))) except Exception as e: current_app.logger.error("An exception occurred ::" + str(e)) Loading @@ -76,7 +76,8 @@ class Notifications(): async def send_request(self, url, data): async with aiohttp.ClientSession() as session: timeout = aiohttp.ClientTimeout(total=10) # Establecer timeout a 10 segundos async with session.post(url, json=data, timeout=timeout) as response: headers = {'content-type': 'application/json'} async with session.post(url, json=data, timeout=timeout, headers=headers) as response: return await response.text() async def send(self, url, data): Loading
services/clean_capif_docker_services.sh +2 −0 Original line number Diff line number Diff line Loading @@ -74,4 +74,6 @@ done docker network rm capif-network docker volume prune --all --force echo "Clean complete."
tests/features/CAPIF Api Events/capif_events_api.robot +182 −9 Original line number Diff line number Diff line Loading @@ -5,7 +5,6 @@ Library XML Resource /opt/robot-tests/tests/resources/common/basicRequests.robot Resource ../../resources/common.resource Suite Teardown Reset Testing Environment Test Setup Reset Testing Environment Loading Loading @@ -139,13 +138,119 @@ Deletes an individual CAPIF Event Subscription with invalid SubscriptionId ... detail=User not authorized ... cause=You are not the owner of this resource Prueba JMS [Tags] jms-1 # Log "Prueba 1" # Wait For Request # Create a log entry # [Tags] capif_api_logging_service-1 # Start Mock server Check Mock Server Clean Mock Server # Register APF ${register_user_info}= Provider Default Registration # Publish one api Publish Service Api ${register_user_info} # Register INVOKER ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding ${discover_response}= Get Request Capif ... ${DISCOVER_URL}${register_user_info_invoker['api_invoker_id']} ... server=${CAPIF_HTTPS_URL} ... verify=ca.crt ... username=${INVOKER_USERNAME} ${api_ids} ${api_names}= Get Api Ids And Names From Discover Response ${discover_response} # Subscribe to events ${events_list}= Create List SERVICE_API_INVOCATION_SUCCESS SERVICE_API_INVOCATION_FAILURE ${request_body}= Create Events Subscription ... events=@{events_list} ... notificationDestination=http://192.168.0.14:9090/testing ${resp}= Post Request Capif ... /capif-events/v1/${register_user_info_invoker['api_invoker_id']}/subscriptions ... json=${request_body} ... server=${CAPIF_HTTPS_URL} ... verify=ca.crt ... username=${INVOKER_USERNAME} # Check Results Check Response Variable Type And Values ${resp} 201 EventSubscription ${subscriber_id} ${subscription_id}= Check Event Location Header ${resp} ${results}= Create List 200 400 # Create Log Entry ${request_body}= Create Log Entry ... ${register_user_info['aef_id']} ... ${register_user_info_invoker['api_invoker_id']} ... ${api_ids} ... ${api_names} ... results=${results} ${resp}= Post Request Capif ... /api-invocation-logs/v1/${register_user_info['aef_id']}/logs ... json=${request_body} ... server=${CAPIF_HTTPS_URL} ... verify=ca.crt ... username=${AEF_PROVIDER_USERNAME} # Check Results Check Response Variable Type And Values ${resp} 201 InvocationLog ${resource_url}= Check Location Header ${resp} ${LOCATION_LOGGING_RESOURCE_REGEX} Sleep 3s # Get from Mock server the EventNotification Messages sent to callback setup on event subscription. ${resp}= Get Mock Server Messages ${notification_events_on_mock_server}= Set Variable ${resp.json()} # Check if message follow EventNotification definition. Check Variable ${notification_events_on_mock_server} EventNotification # Check if mock server receive 2 events. Length Should Be ${notification_events_on_mock_server} 2 # Now we create the expected events received at notification server according to logs sent to loggin service in order to check if all are present. ${invocation_log_base}= Copy Dictionary ${request_body} deepcopy=True # Store log array because each log will be notified in one Event Notification ${invocation_log_logs}= Set Variable ${invocation_log_base['logs']} # Remove logs array from invocationLog data Remove From Dictionary ${invocation_log_base} logs Length Should Be ${invocation_log_logs} 2 # Create 2 invocationLogs from initial invocationLog present on request ${invocation_logs_1}= Copy Dictionary ${invocation_log_base} deepcopy=True ${invocation_logs_2}= Copy Dictionary ${invocation_log_base} deepcopy=True # Create a log array with only one component ${log_1}= Create List ${invocation_log_logs[0]} ${log_2}= Create List ${invocation_log_logs[1]} # Setup logs array with previously created list Set To Dictionary ${invocation_logs_1} logs=${log_1} Set To Dictionary ${invocation_logs_2} logs=${log_2} # Create event details for each log ${event_details_1}= Create dictionary invocationLogs=${invocation_logs_1} ${event_details_2}= Create dictionary invocationLogs=${invocation_logs_2} # Create Event with Event Details from invocationLog ${event_1}= Create Dictionary ... subscriptionId=${subscription_id} ... events=SERVICE_API_INVOCATION_SUCCESS ... eventDetail=${event_details_1} ${event_2}= Create Dictionary ... subscriptionId=${subscription_id} ... events=SERVICE_API_INVOCATION_FAILURE ... eventDetail=${event_details_2} # Check if created events follow EventNotification format defined by 3gpp Check Variable ${event_1} EventNotification Check Variable ${event_2} EventNotification List Should Contain Value ${notification_events_on_mock_server} ${event_1} List Should Contain Value ${notification_events_on_mock_server} ${event_2} Prueba JMS [Tags] jms-2 # Start Mock server Check Mock Server Clean Mock Server # Register APF ${register_user_info}= Provider Default Registration Loading @@ -166,7 +271,9 @@ Prueba JMS # Subscribe to events ${events_list}= Create List SERVICE_API_INVOCATION_SUCCESS SERVICE_API_INVOCATION_FAILURE ${request_body}= Create Events Subscription events=@{events_list} notificationDestination=http://192.168.0.119:9090/testing ${request_body}= Create Events Subscription ... events=@{events_list} ... notificationDestination=http://192.168.0.14:9090/testing ${resp}= Post Request Capif ... /capif-events/v1/${register_user_info_invoker['api_invoker_id']}/subscriptions ... json=${request_body} Loading @@ -178,13 +285,15 @@ Prueba JMS Check Response Variable Type And Values ${resp} 201 EventSubscription ${subscriber_id} ${subscription_id}= Check Event Location Header ${resp} ${results}= Create List 200 400 # Create Log Entry ${request_body}= Create Log Entry ... ${register_user_info['aef_id']} ... ${register_user_info_invoker['api_invoker_id']} ... ${api_ids} ... ${api_names} ... 200 ... results=${results} ${resp}= Post Request Capif ... /api-invocation-logs/v1/${register_user_info['aef_id']}/logs ... json=${request_body} Loading @@ -196,3 +305,67 @@ Prueba JMS Check Response Variable Type And Values ${resp} 201 InvocationLog ${resource_url}= Check Location Header ${resp} ${LOCATION_LOGGING_RESOURCE_REGEX} Sleep 3s # Get from Mock server the EventNotification Messages sent to callback setup on event subscription. ${resp}= Get Mock Server Messages ${notification_events_on_mock_server}= Set Variable ${resp.json()} # Check if message follow EventNotification definition. Check Variable ${notification_events_on_mock_server} EventNotification # Create check Events to ensure all notifications were received ${check_events} ${check_events_length}= Create Events From invocationLogs ... ${subscription_id} ... ${request_body} # Number of events received must be equal than events expected Length Should Be ${notification_events_on_mock_server} ${check_events_length} # Check if events received are the same than expected FOR ${event} IN @{check_events} Log ${event} List Should Contain Value ${notification_events_on_mock_server} ${event} END *** Keywords *** Create Events From invocationLogs [Arguments] ${subscription_id} ${invocation_log} ${events}= Create List # Now we create the expected events received at notification server according to logs sent to loggin service in order to check if all are present. ${invocation_log_base}= Copy Dictionary ${invocation_log} deepcopy=True # Store log array because each log will be notified in one Event Notification ${invocation_log_logs}= Copy List ${invocation_log_base['logs']} # Remove logs array from invocationLog data Remove From Dictionary ${invocation_log_base} logs FOR ${log} IN @{invocation_log_logs} Log Dictionary ${log} ${invocation_logs}= Copy Dictionary ${invocation_log_base} deepcopy=True # Get Event Enum for this result ${event_enum}= Set Variable IF ${log['result']} >= 200 and ${log['result']} < 300 ${event_enum}= Set Variable SERVICE_API_INVOCATION_SUCCESS ELSE ${event_enum}= Set Variable SERVICE_API_INVOCATION_FAILURE END # Create a log array with only one component ${log_list}= Create List ${log} # Setup logs array with previously created list Set To Dictionary ${invocation_logs} logs=${log_list} # Create event details for each log ${event_details}= Create dictionary invocationLogs=${invocation_logs} # Create Event with Event Details from invocationLog and also is appended to events array ${event}= Create Dictionary ... subscriptionId=${subscription_id} ... events=${event_enum} ... eventDetail=${event_details} Check Variable ${event} EventNotification Append To List ${events} ${event} END Log List ${events} ${events_length}= Get Length ${events} RETURN ${events} ${events_length}
tests/libraries/api_logging_service/bodyRequests.py +34 −80 Original line number Diff line number Diff line def create_log_entry(aefId, apiInvokerId, apiId, apiName, result='200'): def create_log_entry(aefId, apiInvokerId, apiId, apiName, results=['200']): data = { "aefId": aefId, "apiInvokerId": apiInvokerId, "logs": [ { "apiId": apiId[0], "apiName": apiName[0], "apiVersion": "v1", "resourceName": "string", "uri": "http://resource/endpoint", "protocol": "HTTP_1_1", "operation": "GET", "result": result, "invocationTime": "2023-03-30T10:30:21.408Z", "invocationLatency": 0, "inputParameters": "string", "outputParameters": "string", "srcInterface": { "ipv4Addr": "192.168.1.1", "fqdn": "string", "port": 65535, "apiPrefix": "string", "securityMethods": [ "PSK", "string" ] }, "destInterface": { "ipv4Addr": "192.168.1.23", "fqdn": "string", "port": 65535, "apiPrefix": "string", "securityMethods": [ "PSK", "string" ] }, "fwdInterface": "string" }, { "apiId": apiId[0], "apiName": apiName[0], "apiVersion": "v2", "resourceName": "string", "uri": "http://resource/endpoint", "protocol": "HTTP_1_1", "operation": "GET", "result": result, "invocationTime": "2023-03-30T10:30:21.408Z", "invocationLatency": 0, "inputParameters": "string", "outputParameters": "string", "srcInterface": { "ipv4Addr": "192.168.1.1", "fqdn": "string", "port": 65535, "apiPrefix": "string", "securityMethods": [ "PSK", "string" ] }, "destInterface": { "ipv4Addr": "192.168.1.23", "fqdn": "string", "port": 65535, "apiPrefix": "string", "securityMethods": [ "PSK", "string" ] }, "fwdInterface": "string" } ], "logs": [], "supportedFeatures": "ffff" } if len(results) > 0: for result in results: data['logs'].append(create_log(apiId,apiName,result)) return data def create_log_entry_bad_service(aefId, apiInvokerId, result=500): Loading @@ -92,28 +24,24 @@ def create_log_entry_bad_service(aefId, apiInvokerId, result=500): "protocol": "HTTP_1_1", "operation": "GET", "result": result, "invocationTime": "2023-03-30T10:30:21.408Z", "invocationTime": "2023-03-30T10:30:21.408000+00:00", "invocationLatency": 0, "inputParameters": "string", "outputParameters": "string", "srcInterface": { "ipv4Addr": "192.168.1.1", "fqdn": "string", "port": 65535, "apiPrefix": "string", "securityMethods": [ "PSK", "string" "PKI" ] }, "destInterface": { "ipv4Addr": "192.168.1.23", "fqdn": "string", "port": 65535, "apiPrefix": "string", "securityMethods": [ "PSK", "string" "PKI" ] }, "fwdInterface": "string" Loading @@ -131,3 +59,29 @@ def get_api_ids_and_names_from_discover_response(discover_response): api_ids.append(service_api_description['apiId']) api_names.append(service_api_description['apiName']) return api_ids, api_names def create_log(apiId, apiName, result): log= { "apiId": apiId[0], "apiName": apiName[0], "apiVersion": "v1", "resourceName": "string", "uri": "http://resource/endpoint", "protocol": "HTTP_1_1", "operation": "GET", "result": result, "invocationTime": "2023-03-30T10:30:21.408000+00:00", "invocationLatency": 0, "inputParameters": "string", "outputParameters": "string", "srcInterface": { "ipv4Addr": "192.168.1.1", "port": 65535, "securityMethods": [ "PSK", "PKI" ] } } return log No newline at end of file