From 30208605bf9a75f134488a7bebf9ab7dea47cb57 Mon Sep 17 00:00:00 2001 From: Jorge Moratinos Salcines Date: Fri, 22 Nov 2024 08:24:46 +0100 Subject: [PATCH 1/8] Added new regex type under types --- tests/libraries/common/bodyRequests.py | 26 ++++++++++++++++++++++---- tests/libraries/common/types.json | 6 ++++++ 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/tests/libraries/common/bodyRequests.py b/tests/libraries/common/bodyRequests.py index 1d4ec14..71fc9b9 100644 --- a/tests/libraries/common/bodyRequests.py +++ b/tests/libraries/common/bodyRequests.py @@ -32,7 +32,7 @@ def check_variable(input, data_type): else: raise Exception("variable is not integer type") elif data_type == "URI": - check_uri(input,data_type) + check_uri(input, data_type) return True elif data_type == "URI_reference": check_uri(input, data_type) @@ -70,13 +70,29 @@ def check_variable(input, data_type): def check_attributes_dict(body, data_type): mandatory_attributes = capif_types[data_type]["mandatory_attributes"] optional_parameters = capif_types[data_type]["optional_attributes"] + regex_attributes = capif_types[data_type]["regex_attributes"] + all_attributes = mandatory_attributes | optional_parameters # Check if body has not allowed attributes for body_key in body.keys(): + print(body_key) if body_key not in all_attributes.keys(): - raise Exception('Attribute "' + body_key + - '" is not present as a mandatory or optional key (' + ','.join(all_attributes.keys()) + ')') + print(body_key + " NOT IN ALL ATTRIBUTES") + present = False + if regex_attributes is not None: + print("REGEX ATTRIBUTES PRESENT") + print(regex_attributes) + for regex_key, regex_data_type in regex_attributes.items(): + print(regex_key + ":" + regex_data_type) + if check_regex(body_key, regex_key): + print("MATCH with " + body_key) + present = True + all_attributes[body_key] = regex_data_type + break + if not present: + raise Exception('Attribute "' + body_key + + '" is not present as a mandatory or optional key (' + ','.join(all_attributes.keys()) + ')') if mandatory_attributes: for mandatory_key in mandatory_attributes.keys(): @@ -110,16 +126,18 @@ def sign_csr_body(username, public_key): return data -def check_uri(input,rule): +def check_uri(input, rule): if rfc3987.match(input, rule=rule) is not None: return input else: raise Exception(rule + " is not accomplish rfc3986 rule ("+input+")") + def check_regex(input, regex): matched = re.match(regex, input) is_match = bool(matched) if is_match: print("Regex match") + return True else: raise Exception("Input(" + input + ") not match regex (" + regex + ")") diff --git a/tests/libraries/common/types.json b/tests/libraries/common/types.json index 220dd0f..85a27ad 100644 --- a/tests/libraries/common/types.json +++ b/tests/libraries/common/types.json @@ -83,8 +83,14 @@ "apiSuppFeats": "SupportedFeatures", "pubApiPath": "PublishedApiPath", "ccfId": "string" + }, + "regex_attributes": { + "^vendorSpecific-(.*)": "VendorSpecificObject" } }, + "VendorSpecificObject": { + "Check": false + }, "AefProfile": { "mandatory_attributes": { "aefId": "string", -- GitLab From d3305ba42b68fbdce40b24504c4e4810f3313f4f Mon Sep 17 00:00:00 2001 From: Jorge Moratinos Salcines Date: Fri, 22 Nov 2024 11:27:58 +0100 Subject: [PATCH 2/8] Adding tests for vendor extensibility --- .../Vendor Extensibility/__init__.robot | 2 + .../vendor_extensibility.robot | 51 +++++++++++++++++++ .../api_publish_service/bodyRequests.py | 17 +++++-- tests/libraries/bodyRequests.py | 2 +- tests/libraries/common/bodyRequests.py | 2 +- tests/libraries/common/types.json | 3 ++ .../vendor_extensibility/bodyRequests.py | 34 +++++++++++++ tests/resources/common/basicRequests.robot | 4 +- 8 files changed, 108 insertions(+), 7 deletions(-) create mode 100644 tests/features/Vendor Extensibility/__init__.robot create mode 100644 tests/features/Vendor Extensibility/vendor_extensibility.robot create mode 100644 tests/libraries/vendor_extensibility/bodyRequests.py diff --git a/tests/features/Vendor Extensibility/__init__.robot b/tests/features/Vendor Extensibility/__init__.robot new file mode 100644 index 0000000..cdcb853 --- /dev/null +++ b/tests/features/Vendor Extensibility/__init__.robot @@ -0,0 +1,2 @@ +*** Settings *** +Force Tags vendor_extensibility \ No newline at end of file diff --git a/tests/features/Vendor Extensibility/vendor_extensibility.robot b/tests/features/Vendor Extensibility/vendor_extensibility.robot new file mode 100644 index 0000000..3c0c30a --- /dev/null +++ b/tests/features/Vendor Extensibility/vendor_extensibility.robot @@ -0,0 +1,51 @@ +*** Settings *** +Resource /opt/robot-tests/tests/resources/common.resource +Resource /opt/robot-tests/tests/resources/api_invoker_management_requests/apiInvokerManagementRequests.robot +Resource ../../resources/common.resource +Library /opt/robot-tests/tests/libraries/bodyRequests.py + +Suite Teardown Reset Testing Environment +Test Setup Reset Testing Environment +Test Teardown Reset Testing Environment + + +*** Variables *** +${API_INVOKER_NOT_REGISTERED} not-valid + + +*** Test Cases *** +Discover Published service APIs by Authorised API Invoker + [Tags] vendor_extensibility-1 + # Register APF + ${register_user_info}= Provider Default Registration + + # Create Vendor Specific information + ${vendor_specific_service_api_description}= Create Vendor Specific Service Api Description + ... vendorSpecific-urn:etsi:mec:capifext:service-info + ${vendor_specific_aef_profile}= Create Vendor Specific Aef Profile + ... vendorSpecific-urn:etsi:mec:capifext:transport-info + + # Publish one api + ${service_api_description_published} ${resource_url} ${request_body}= Publish Service Api + ... ${register_user_info} + ... supported_features=10 + ... vendor_specific_service_api_description=${vendor_specific_service_api_description} + ... vendor_specific_aef_profile=${vendor_specific_aef_profile} + + # Default Invoker Registration and Onboarding + ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding + + # Test + ${resp}= Get Request Capif + ... ${DISCOVER_URL}${register_user_info_invoker['api_invoker_id']}&aef-id=${register_user_info['aef_id']} + ... server=${CAPIF_HTTPS_URL} + ... verify=ca.crt + ... username=${INVOKER_USERNAME} + + Check Response Variable Type And Values ${resp} 200 DiscoveredAPIs + + # Check Results + Dictionary Should Contain Key ${resp.json()} serviceAPIDescriptions + Should Not Be Empty ${resp.json()['serviceAPIDescriptions']} + Length Should Be ${resp.json()['serviceAPIDescriptions']} 1 + List Should Contain Value ${resp.json()['serviceAPIDescriptions']} ${service_api_description_published} diff --git a/tests/libraries/api_publish_service/bodyRequests.py b/tests/libraries/api_publish_service/bodyRequests.py index 69e7bb1..f6317f6 100644 --- a/tests/libraries/api_publish_service/bodyRequests.py +++ b/tests/libraries/api_publish_service/bodyRequests.py @@ -1,5 +1,5 @@ -def create_service_api_description(api_name="service_1",aef_id="aef_id"): - return { +def create_service_api_description(api_name="service_1", aef_id="aef_id", supported_features="fffff", vendor_specific_service_api_description=None, vendor_specific_aef_profile=None): + body = { "apiName": api_name, "aefProfiles": [ { @@ -35,7 +35,7 @@ def create_service_api_description(api_name="service_1",aef_id="aef_id"): } ], "description": "ROBOT_TESTING", - "supportedFeatures": "fffff", + "supportedFeatures": supported_features, "shareableInfo": { "isShareable": True, "capifProvDoms": [ @@ -51,3 +51,14 @@ def create_service_api_description(api_name="service_1",aef_id="aef_id"): }, "ccfId": "string" } + + if vendor_specific_service_api_description is not None: + if isinstance(vendor_specific_service_api_description, dict): + for key, value in vendor_specific_service_api_description.items(): + body[key] = value + if vendor_specific_aef_profile is not None: + if isinstance(vendor_specific_aef_profile, dict): + for key, value in vendor_specific_aef_profile.items(): + body["aefProfiles"][0][key] = value + + return body diff --git a/tests/libraries/bodyRequests.py b/tests/libraries/bodyRequests.py index 5e45124..30597ba 100644 --- a/tests/libraries/bodyRequests.py +++ b/tests/libraries/bodyRequests.py @@ -5,4 +5,4 @@ from api_publish_service.bodyRequests import * from api_events.bodyRequests import * from security_api.bodyRequests import * from api_provider_management.bodyRequests import * - +from vendor_extensibility.bodyRequests import * diff --git a/tests/libraries/common/bodyRequests.py b/tests/libraries/common/bodyRequests.py index 71fc9b9..b0829b7 100644 --- a/tests/libraries/common/bodyRequests.py +++ b/tests/libraries/common/bodyRequests.py @@ -70,7 +70,7 @@ def check_variable(input, data_type): def check_attributes_dict(body, data_type): mandatory_attributes = capif_types[data_type]["mandatory_attributes"] optional_parameters = capif_types[data_type]["optional_attributes"] - regex_attributes = capif_types[data_type]["regex_attributes"] + regex_attributes = capif_types[data_type].get("regex_attributes",{}) all_attributes = mandatory_attributes | optional_parameters # Check if body has not allowed attributes diff --git a/tests/libraries/common/types.json b/tests/libraries/common/types.json index 85a27ad..f2f0ff8 100644 --- a/tests/libraries/common/types.json +++ b/tests/libraries/common/types.json @@ -104,6 +104,9 @@ "interfaceDescriptions": "InterfaceDescription", "aefLocation": "AefLocation" }, + "regex_attributes": { + "^vendorSpecific-(.*)": "VendorSpecificObject" + }, "oneOf": ["interfaceDescriptions", "domainName"] }, "Version": { diff --git a/tests/libraries/vendor_extensibility/bodyRequests.py b/tests/libraries/vendor_extensibility/bodyRequests.py new file mode 100644 index 0000000..0e4e5bc --- /dev/null +++ b/tests/libraries/vendor_extensibility/bodyRequests.py @@ -0,0 +1,34 @@ +def create_vendor_specific_service_api_description(vendor_specific_key): + vendor_dict = { + vendor_specific_key: { + "serializer": "JSON", + "state": "ACTIVE", + "scopeOfLocality": "MEC_SYSTEM", + "consumedLocalOnly": "True", + "isLocal": "True", + "category": { + "href": "https://www.location.com", + "id": "location_1", + "name": "Location", + "version": "1.0" + } + } + } + return vendor_dict + + +def create_vendor_specific_aef_profile(vendor_specific_key): + vendor_dict = { + vendor_specific_key: { + "name": "trasport1", + "description": "Transport Info 1", + "type": "REST_HTTP", + "protocol": "HTTP", + "version": "2", + "security": { + "grantTypes": "OAUTH2_CLIENT_CREDENTIALS", + "tokenEndpoint": "https://token-endpoint/" + } + } + } + return vendor_dict diff --git a/tests/resources/common/basicRequests.robot b/tests/resources/common/basicRequests.robot index 838086f..58374be 100644 --- a/tests/resources/common/basicRequests.robot +++ b/tests/resources/common/basicRequests.robot @@ -686,9 +686,9 @@ Provider Default Registration RETURN ${register_user_info} Publish Service Api - [Arguments] ${register_user_info_provider} ${service_name}=service_1 + [Arguments] ${register_user_info_provider} ${service_name}=service_1 ${supported_features}=fffff ${vendor_specific_service_api_description}=${None} ${vendor_specific_aef_profile}=${None} - ${request_body}= Create Service Api Description ${service_name} ${register_user_info_provider['aef_id']} + ${request_body}= Create Service Api Description ${service_name} ${register_user_info_provider['aef_id']} ${supported_features} ${vendor_specific_service_api_description} ${vendor_specific_aef_profile} ${resp}= Post Request Capif ... /published-apis/v1/${register_user_info_provider['apf_id']}/service-apis ... json=${request_body} -- GitLab From 7ab016c4d8fdaaa51c93a764aca48ade804a220d Mon Sep 17 00:00:00 2001 From: Jorge Moratinos Salcines Date: Fri, 22 Nov 2024 11:46:42 +0100 Subject: [PATCH 3/8] Adding two initial tests for vendor extensibility --- .../vendor_extensibility.robot | 55 +++++++++++++++++-- 1 file changed, 51 insertions(+), 4 deletions(-) diff --git a/tests/features/Vendor Extensibility/vendor_extensibility.robot b/tests/features/Vendor Extensibility/vendor_extensibility.robot index 3c0c30a..de698ba 100644 --- a/tests/features/Vendor Extensibility/vendor_extensibility.robot +++ b/tests/features/Vendor Extensibility/vendor_extensibility.robot @@ -14,24 +14,29 @@ ${API_INVOKER_NOT_REGISTERED} not-valid *** Test Cases *** -Discover Published service APIs by Authorised API Invoker +Vendor Extensibility published with vendorExt active [Tags] vendor_extensibility-1 + ${vendor_specific_service_api_key}= Set Variable vendorSpecific-urn:etsi:mec:capifext:service-info + ${vendor_specific_aef_profile_key}= Set Variable vendorSpecific-urn:etsi:mec:capifext:transport-info # Register APF ${register_user_info}= Provider Default Registration # Create Vendor Specific information ${vendor_specific_service_api_description}= Create Vendor Specific Service Api Description - ... vendorSpecific-urn:etsi:mec:capifext:service-info + ... ${vendor_specific_service_api_key} ${vendor_specific_aef_profile}= Create Vendor Specific Aef Profile - ... vendorSpecific-urn:etsi:mec:capifext:transport-info + ... ${vendor_specific_aef_profile_key} # Publish one api ${service_api_description_published} ${resource_url} ${request_body}= Publish Service Api ... ${register_user_info} - ... supported_features=10 + ... supported_features=100 ... vendor_specific_service_api_description=${vendor_specific_service_api_description} ... vendor_specific_aef_profile=${vendor_specific_aef_profile} + Dictionary Should Contain Key ${service_api_description_published} ${vendor_specific_service_api_key} + Dictionary Should Contain Key ${service_api_description_published['aefProfiles'][0]} ${vendor_specific_aef_profile_key} + # Default Invoker Registration and Onboarding ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding @@ -49,3 +54,45 @@ Discover Published service APIs by Authorised API Invoker Should Not Be Empty ${resp.json()['serviceAPIDescriptions']} Length Should Be ${resp.json()['serviceAPIDescriptions']} 1 List Should Contain Value ${resp.json()['serviceAPIDescriptions']} ${service_api_description_published} + + +Vendor Extensibility published with vendorExt not active + [Tags] vendor_extensibility-2 + ${vendor_specific_service_api_key}= Set Variable vendorSpecific-urn:etsi:mec:capifext:service-info + ${vendor_specific_aef_profile_key}= Set Variable vendorSpecific-urn:etsi:mec:capifext:transport-info + # Register APF + ${register_user_info}= Provider Default Registration + + # Create Vendor Specific information + ${vendor_specific_service_api_description}= Create Vendor Specific Service Api Description + ... ${vendor_specific_service_api_key} + ${vendor_specific_aef_profile}= Create Vendor Specific Aef Profile + ... ${vendor_specific_aef_profile_key} + + # Publish one api + ${service_api_description_published} ${resource_url} ${request_body}= Publish Service Api + ... ${register_user_info} + ... supported_features=000 + ... vendor_specific_service_api_description=${vendor_specific_service_api_description} + ... vendor_specific_aef_profile=${vendor_specific_aef_profile} + + Dictionary Should Not Contain Key ${service_api_description_published} ${vendor_specific_service_api_key} + Dictionary Should Not Contain Key ${service_api_description_published['aefProfiles'][0]} ${vendor_specific_aef_profile_key} + + # Default Invoker Registration and Onboarding + ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding + + # Test + ${resp}= Get Request Capif + ... ${DISCOVER_URL}${register_user_info_invoker['api_invoker_id']}&aef-id=${register_user_info['aef_id']} + ... server=${CAPIF_HTTPS_URL} + ... verify=ca.crt + ... username=${INVOKER_USERNAME} + + Check Response Variable Type And Values ${resp} 200 DiscoveredAPIs + + # Check Results + Dictionary Should Contain Key ${resp.json()} serviceAPIDescriptions + Should Not Be Empty ${resp.json()['serviceAPIDescriptions']} + Length Should Be ${resp.json()['serviceAPIDescriptions']} 1 + List Should Contain Value ${resp.json()['serviceAPIDescriptions']} ${service_api_description_published} \ No newline at end of file -- GitLab From 981db31e0d0d9ed15206ab0db2854aba9df2b994 Mon Sep 17 00:00:00 2001 From: Jorge Moratinos Salcines Date: Tue, 26 Nov 2024 13:53:11 +0100 Subject: [PATCH 4/8] Created tests according to testplan for vendor extensibility --- .../vendor_extensibility.robot | 216 +++++++++++++++++- .../api_publish_service/bodyRequests.py | 3 +- 2 files changed, 210 insertions(+), 9 deletions(-) diff --git a/tests/features/Vendor Extensibility/vendor_extensibility.robot b/tests/features/Vendor Extensibility/vendor_extensibility.robot index de698ba..583b3ee 100644 --- a/tests/features/Vendor Extensibility/vendor_extensibility.robot +++ b/tests/features/Vendor Extensibility/vendor_extensibility.robot @@ -14,7 +14,7 @@ ${API_INVOKER_NOT_REGISTERED} not-valid *** Test Cases *** -Vendor Extensibility published with vendorExt active +Published API with vendor extensibility [Tags] vendor_extensibility-1 ${vendor_specific_service_api_key}= Set Variable vendorSpecific-urn:etsi:mec:capifext:service-info ${vendor_specific_aef_profile_key}= Set Variable vendorSpecific-urn:etsi:mec:capifext:transport-info @@ -42,7 +42,7 @@ Vendor Extensibility published with vendorExt active # Test ${resp}= Get Request Capif - ... ${DISCOVER_URL}${register_user_info_invoker['api_invoker_id']}&aef-id=${register_user_info['aef_id']} + ... ${DISCOVER_URL}${register_user_info_invoker['api_invoker_id']}&aef-id=${register_user_info['aef_id']}&supported_features=2 ... server=${CAPIF_HTTPS_URL} ... verify=ca.crt ... username=${INVOKER_USERNAME} @@ -55,8 +55,7 @@ Vendor Extensibility published with vendorExt active Length Should Be ${resp.json()['serviceAPIDescriptions']} 1 List Should Contain Value ${resp.json()['serviceAPIDescriptions']} ${service_api_description_published} - -Vendor Extensibility published with vendorExt not active +Published API with vendor extensibility and discover with VendSpecQueryParams disabled [Tags] vendor_extensibility-2 ${vendor_specific_service_api_key}= Set Variable vendorSpecific-urn:etsi:mec:capifext:service-info ${vendor_specific_aef_profile_key}= Set Variable vendorSpecific-urn:etsi:mec:capifext:transport-info @@ -72,12 +71,54 @@ Vendor Extensibility published with vendorExt not active # Publish one api ${service_api_description_published} ${resource_url} ${request_body}= Publish Service Api ... ${register_user_info} - ... supported_features=000 + ... supported_features=100 ... vendor_specific_service_api_description=${vendor_specific_service_api_description} ... vendor_specific_aef_profile=${vendor_specific_aef_profile} - Dictionary Should Not Contain Key ${service_api_description_published} ${vendor_specific_service_api_key} - Dictionary Should Not Contain Key ${service_api_description_published['aefProfiles'][0]} ${vendor_specific_aef_profile_key} + Dictionary Should Contain Key ${service_api_description_published} ${vendor_specific_service_api_key} + Dictionary Should Contain Key ${service_api_description_published['aefProfiles'][0]} ${vendor_specific_aef_profile_key} + + # Default Invoker Registration and Onboarding + ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding + + # Test + ${resp}= Get Request Capif + ... ${DISCOVER_URL}${register_user_info_invoker['api_invoker_id']}&aef-id=${register_user_info['aef_id']}&supported_features=0 + ... server=${CAPIF_HTTPS_URL} + ... verify=ca.crt + ... username=${INVOKER_USERNAME} + + Check Response Variable Type And Values + ... ${resp} + ... 404 + ... ProblemDetails + ... title=Not Found + ... status=404 + ... detail=API Invoker ${register_user_info_invoker['api_invoker_id']} has no API Published that accomplish filter conditions + ... cause=No API Published accomplish filter conditions + +Publish API with vendorExt active and discover without supported features filter + [Tags] vendor_extensibility-3 + ${vendor_specific_service_api_key}= Set Variable vendorSpecific-urn:etsi:mec:capifext:service-info + ${vendor_specific_aef_profile_key}= Set Variable vendorSpecific-urn:etsi:mec:capifext:transport-info + # Register APF + ${register_user_info}= Provider Default Registration + + # Create Vendor Specific information + ${vendor_specific_service_api_description}= Create Vendor Specific Service Api Description + ... ${vendor_specific_service_api_key} + ${vendor_specific_aef_profile}= Create Vendor Specific Aef Profile + ... ${vendor_specific_aef_profile_key} + + # Publish one api + ${service_api_description_published} ${resource_url} ${request_body}= Publish Service Api + ... ${register_user_info} + ... supported_features=100 + ... vendor_specific_service_api_description=${vendor_specific_service_api_description} + ... vendor_specific_aef_profile=${vendor_specific_aef_profile} + + Dictionary Should Contain Key ${service_api_description_published} ${vendor_specific_service_api_key} + Dictionary Should Contain Key ${service_api_description_published['aefProfiles'][0]} ${vendor_specific_aef_profile_key} # Default Invoker Registration and Onboarding ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding @@ -95,4 +136,163 @@ Vendor Extensibility published with vendorExt not active Dictionary Should Contain Key ${resp.json()} serviceAPIDescriptions Should Not Be Empty ${resp.json()['serviceAPIDescriptions']} Length Should Be ${resp.json()['serviceAPIDescriptions']} 1 - List Should Contain Value ${resp.json()['serviceAPIDescriptions']} ${service_api_description_published} \ No newline at end of file + Dictionary Should Not Contain Key ${resp.json()['serviceAPIDescriptions']} ${vendor_specific_service_api_key} + Dictionary Should Not Contain Key ${resp.json()['serviceAPIDescriptions']['aefProfiles'][0]} ${vendor_specific_aef_profile_key} + + ${service_api_description_published_to_check}= Copy Dictionary ${service_api_description_published} deepcopy=True + Remove From Dictionary ${service_api_description_published_to_check} ${vendor_specific_service_api_key} + Remove From Dictionary ${service_api_description_published_to_check['aefProfiles'][0]} ${vendor_specific_aef_profile_key} + + List Should Contain Value ${resp.json()['serviceAPIDescriptions']} ${service_api_description_published_to_check} + +Publish API with vendorExt active but without vendorSpecifics + [Tags] vendor_extensibility-4 + # Register APF + ${register_user_info}= Provider Default Registration + + # Publish one api + ${service_api_description_published} ${resource_url} ${request_body}= Publish Service Api + ... ${register_user_info} + ... supported_features=100 + + Check Response Variable Type And Values + ... ${resp} + ... 400 + ... ProblemDetails + ... title=Bad Request + ... status=400 + ... detail=VendorExt feature active at Supported Features but VendorSpecifics parameters not published + ... cause=VendorExt feature active but vendorSpecifics not present + +Publish API with vendorExt inactive but with vendorSpecifics + [Tags] vendor_extensibility-5 + ${vendor_specific_service_api_key}= Set Variable vendorSpecific-urn:etsi:mec:capifext:service-info + ${vendor_specific_aef_profile_key}= Set Variable vendorSpecific-urn:etsi:mec:capifext:transport-info + # Register APF + ${register_user_info}= Provider Default Registration + + # Create Vendor Specific information + ${vendor_specific_service_api_description}= Create Vendor Specific Service Api Description + ... ${vendor_specific_service_api_key} + ${vendor_specific_aef_profile}= Create Vendor Specific Aef Profile + ... ${vendor_specific_aef_profile_key} + + # Publish one api + ${service_api_description_published} ${resource_url} ${request_body}= Publish Service Api + ... ${register_user_info} + ... supported_features=0 + ... vendor_specific_service_api_description=${vendor_specific_service_api_description} + ... vendor_specific_aef_profile=${vendor_specific_aef_profile} + + Check Response Variable Type And Values + ... ${resp} + ... 400 + ... ProblemDetails + ... title=Bad Request + ... status=400 + ... detail=VendorExt feature inactive at Supported Features but VendorSpecifics are present parameters published + ... cause=VendorExt feature inactive but vendorSpecifics present + +Published API without vendor extensibility discover with VendSpecQueryParams enabled + [Tags] vendor_extensibility-6 + # Register APF + ${register_user_info}= Provider Default Registration + + # Publish one api + ${service_api_description_published} ${resource_url} ${request_body}= Publish Service Api + ... ${register_user_info} + ... supported_features=000 + + # Default Invoker Registration and Onboarding + ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding + + # Test + ${resp}= Get Request Capif + ... ${DISCOVER_URL}${register_user_info_invoker['api_invoker_id']}&aef-id=${register_user_info['aef_id']}&supported_features=2 + ... server=${CAPIF_HTTPS_URL} + ... verify=ca.crt + ... username=${INVOKER_USERNAME} + + Check Response Variable Type And Values + ... ${resp} + ... 404 + ... ProblemDetails + ... title=Not Found + ... status=404 + ... detail=API Invoker ${register_user_info_invoker['api_invoker_id']} has no API Published that accomplish filter conditions + ... cause=No API Published accomplish filter conditions + +Published API without vendor extensibility and discover with vendSpecQueryParams disabled + [Tags] vendor_extensibility-7 + # Register APF + ${register_user_info}= Provider Default Registration + + # Publish one api + ${service_api_description_published} ${resource_url} ${request_body}= Publish Service Api + ... ${register_user_info} + ... supported_features=00 + + # Default Invoker Registration and Onboarding + ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding + + # Test + ${resp}= Get Request Capif + ... ${DISCOVER_URL}${register_user_info_invoker['api_invoker_id']}&aef-id=${register_user_info['aef_id']}&supported_features=0 + ... server=${CAPIF_HTTPS_URL} + ... verify=ca.crt + ... username=${INVOKER_USERNAME} + + Check Response Variable Type And Values ${resp} 200 DiscoveredAPIs + + # Check Results + Dictionary Should Contain Key ${resp.json()} serviceAPIDescriptions + Should Not Be Empty ${resp.json()['serviceAPIDescriptions']} + Length Should Be ${resp.json()['serviceAPIDescriptions']} 1 + List Should Contain Value ${resp.json()['serviceAPIDescriptions']} ${service_api_description_published} + +Published API without vendor extensibility and discover without supported-features query parameter + [Tags] vendor_extensibility-8 + # Register APF + ${register_user_info}= Provider Default Registration + + # Publish one api + ${service_api_description_published} ${resource_url} ${request_body}= Publish Service Api + ... ${register_user_info} + ... supported_features=00 + + # Default Invoker Registration and Onboarding + ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding + + # Test + ${resp}= Get Request Capif + ... ${DISCOVER_URL}${register_user_info_invoker['api_invoker_id']}&aef-id=${register_user_info['aef_id']} + ... server=${CAPIF_HTTPS_URL} + ... verify=ca.crt + ... username=${INVOKER_USERNAME} + + Check Response Variable Type And Values ${resp} 200 DiscoveredAPIs + + # Check Results + Dictionary Should Contain Key ${resp.json()} serviceAPIDescriptions + Should Not Be Empty ${resp.json()['serviceAPIDescriptions']} + Length Should Be ${resp.json()['serviceAPIDescriptions']} 1 + List Should Contain Value ${resp.json()['serviceAPIDescriptions']} ${service_api_description_published} + +Publish API without supportedFeatures + [Tags] vendor_extensibility-9 + # Register APF + ${register_user_info}= Provider Default Registration + + # Publish one api + ${service_api_description_published} ${resource_url} ${request_body}= Publish Service Api + ... ${register_user_info} + ... supported_features=${NONE} + + Check Response Variable Type And Values + ... ${resp} + ... 400 + ... ProblemDetails + ... title=Bad Request + ... status=400 + ... detail=supportedFeatures must be present in this request + ... cause=supportedFeatures missed diff --git a/tests/libraries/api_publish_service/bodyRequests.py b/tests/libraries/api_publish_service/bodyRequests.py index f6317f6..beeb225 100644 --- a/tests/libraries/api_publish_service/bodyRequests.py +++ b/tests/libraries/api_publish_service/bodyRequests.py @@ -35,7 +35,6 @@ def create_service_api_description(api_name="service_1", aef_id="aef_id", suppor } ], "description": "ROBOT_TESTING", - "supportedFeatures": supported_features, "shareableInfo": { "isShareable": True, "capifProvDoms": [ @@ -60,5 +59,7 @@ def create_service_api_description(api_name="service_1", aef_id="aef_id", suppor if isinstance(vendor_specific_aef_profile, dict): for key, value in vendor_specific_aef_profile.items(): body["aefProfiles"][0][key] = value + if supported_features is not None: + body['supportedFeatures'] = supported_features return body -- GitLab From be59544189ce96cc090097600eda53544e542815 Mon Sep 17 00:00:00 2001 From: Jorge Moratinos Salcines Date: Tue, 26 Nov 2024 16:15:47 +0100 Subject: [PATCH 5/8] Minor fixes and code review for vendor extensibility test suite --- .../vendor_extensibility.robot | 89 +++++++++++++------ 1 file changed, 63 insertions(+), 26 deletions(-) diff --git a/tests/features/Vendor Extensibility/vendor_extensibility.robot b/tests/features/Vendor Extensibility/vendor_extensibility.robot index 583b3ee..b14dc71 100644 --- a/tests/features/Vendor Extensibility/vendor_extensibility.robot +++ b/tests/features/Vendor Extensibility/vendor_extensibility.robot @@ -16,8 +16,8 @@ ${API_INVOKER_NOT_REGISTERED} not-valid *** Test Cases *** Published API with vendor extensibility [Tags] vendor_extensibility-1 - ${vendor_specific_service_api_key}= Set Variable vendorSpecific-urn:etsi:mec:capifext:service-info - ${vendor_specific_aef_profile_key}= Set Variable vendorSpecific-urn:etsi:mec:capifext:transport-info + ${vendor_specific_service_api_key}= Set Variable vendorSpecific-urn:etsi:mec:capifext:service-info + ${vendor_specific_aef_profile_key}= Set Variable vendorSpecific-urn:etsi:mec:capifext:transport-info # Register APF ${register_user_info}= Provider Default Registration @@ -35,7 +35,9 @@ Published API with vendor extensibility ... vendor_specific_aef_profile=${vendor_specific_aef_profile} Dictionary Should Contain Key ${service_api_description_published} ${vendor_specific_service_api_key} - Dictionary Should Contain Key ${service_api_description_published['aefProfiles'][0]} ${vendor_specific_aef_profile_key} + Dictionary Should Contain Key + ... ${service_api_description_published['aefProfiles'][0]} + ... ${vendor_specific_aef_profile_key} # Default Invoker Registration and Onboarding ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding @@ -57,8 +59,8 @@ Published API with vendor extensibility Published API with vendor extensibility and discover with VendSpecQueryParams disabled [Tags] vendor_extensibility-2 - ${vendor_specific_service_api_key}= Set Variable vendorSpecific-urn:etsi:mec:capifext:service-info - ${vendor_specific_aef_profile_key}= Set Variable vendorSpecific-urn:etsi:mec:capifext:transport-info + ${vendor_specific_service_api_key}= Set Variable vendorSpecific-urn:etsi:mec:capifext:service-info + ${vendor_specific_aef_profile_key}= Set Variable vendorSpecific-urn:etsi:mec:capifext:transport-info # Register APF ${register_user_info}= Provider Default Registration @@ -76,7 +78,9 @@ Published API with vendor extensibility and discover with VendSpecQueryParams di ... vendor_specific_aef_profile=${vendor_specific_aef_profile} Dictionary Should Contain Key ${service_api_description_published} ${vendor_specific_service_api_key} - Dictionary Should Contain Key ${service_api_description_published['aefProfiles'][0]} ${vendor_specific_aef_profile_key} + Dictionary Should Contain Key + ... ${service_api_description_published['aefProfiles'][0]} + ... ${vendor_specific_aef_profile_key} # Default Invoker Registration and Onboarding ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding @@ -99,8 +103,8 @@ Published API with vendor extensibility and discover with VendSpecQueryParams di Publish API with vendorExt active and discover without supported features filter [Tags] vendor_extensibility-3 - ${vendor_specific_service_api_key}= Set Variable vendorSpecific-urn:etsi:mec:capifext:service-info - ${vendor_specific_aef_profile_key}= Set Variable vendorSpecific-urn:etsi:mec:capifext:transport-info + ${vendor_specific_service_api_key}= Set Variable vendorSpecific-urn:etsi:mec:capifext:service-info + ${vendor_specific_aef_profile_key}= Set Variable vendorSpecific-urn:etsi:mec:capifext:transport-info # Register APF ${register_user_info}= Provider Default Registration @@ -118,7 +122,9 @@ Publish API with vendorExt active and discover without supported features filter ... vendor_specific_aef_profile=${vendor_specific_aef_profile} Dictionary Should Contain Key ${service_api_description_published} ${vendor_specific_service_api_key} - Dictionary Should Contain Key ${service_api_description_published['aefProfiles'][0]} ${vendor_specific_aef_profile_key} + Dictionary Should Contain Key + ... ${service_api_description_published['aefProfiles'][0]} + ... ${vendor_specific_aef_profile_key} # Default Invoker Registration and Onboarding ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding @@ -136,24 +142,41 @@ Publish API with vendorExt active and discover without supported features filter Dictionary Should Contain Key ${resp.json()} serviceAPIDescriptions Should Not Be Empty ${resp.json()['serviceAPIDescriptions']} Length Should Be ${resp.json()['serviceAPIDescriptions']} 1 - Dictionary Should Not Contain Key ${resp.json()['serviceAPIDescriptions']} ${vendor_specific_service_api_key} - Dictionary Should Not Contain Key ${resp.json()['serviceAPIDescriptions']['aefProfiles'][0]} ${vendor_specific_aef_profile_key} + Dictionary Should Not Contain Key + ... ${resp.json()['serviceAPIDescriptions'][0]} + ... ${vendor_specific_service_api_key} + Dictionary Should Not Contain Key + ... ${resp.json()['serviceAPIDescriptions'][0]['aefProfiles'][0]} + ... ${vendor_specific_aef_profile_key} - ${service_api_description_published_to_check}= Copy Dictionary ${service_api_description_published} deepcopy=True - Remove From Dictionary ${service_api_description_published_to_check} ${vendor_specific_service_api_key} - Remove From Dictionary ${service_api_description_published_to_check['aefProfiles'][0]} ${vendor_specific_aef_profile_key} + ${service_api_description_published_to_check}= Copy Dictionary + ... ${service_api_description_published} + ... deepcopy=True + Remove From Dictionary ${service_api_description_published_to_check} ${vendor_specific_service_api_key} + Remove From Dictionary + ... ${service_api_description_published_to_check['aefProfiles'][0]} + ... ${vendor_specific_aef_profile_key} - List Should Contain Value ${resp.json()['serviceAPIDescriptions']} ${service_api_description_published_to_check} + List Should Contain Value + ... ${resp.json()['serviceAPIDescriptions']} + ... ${service_api_description_published_to_check} Publish API with vendorExt active but without vendorSpecifics [Tags] vendor_extensibility-4 # Register APF ${register_user_info}= Provider Default Registration - # Publish one api - ${service_api_description_published} ${resource_url} ${request_body}= Publish Service Api - ... ${register_user_info} + # Publish API with supported features + ${request_body}= Create Service Api Description + ... api_name=service_1 + ... aef_id=${register_user_info['aef_id']} ... supported_features=100 + ${resp}= Post Request Capif + ... /published-apis/v1/${register_user_info['apf_id']}/service-apis + ... json=${request_body} + ... server=${CAPIF_HTTPS_URL} + ... verify=ca.crt + ... username=${register_user_info['apf_username']} Check Response Variable Type And Values ... ${resp} @@ -166,8 +189,8 @@ Publish API with vendorExt active but without vendorSpecifics Publish API with vendorExt inactive but with vendorSpecifics [Tags] vendor_extensibility-5 - ${vendor_specific_service_api_key}= Set Variable vendorSpecific-urn:etsi:mec:capifext:service-info - ${vendor_specific_aef_profile_key}= Set Variable vendorSpecific-urn:etsi:mec:capifext:transport-info + ${vendor_specific_service_api_key}= Set Variable vendorSpecific-urn:etsi:mec:capifext:service-info + ${vendor_specific_aef_profile_key}= Set Variable vendorSpecific-urn:etsi:mec:capifext:transport-info # Register APF ${register_user_info}= Provider Default Registration @@ -177,12 +200,19 @@ Publish API with vendorExt inactive but with vendorSpecifics ${vendor_specific_aef_profile}= Create Vendor Specific Aef Profile ... ${vendor_specific_aef_profile_key} - # Publish one api - ${service_api_description_published} ${resource_url} ${request_body}= Publish Service Api - ... ${register_user_info} + # Publish API with supported features + ${request_body}= Create Service Api Description + ... api_name=service_1 + ... aef_id=${register_user_info['aef_id']} ... supported_features=0 ... vendor_specific_service_api_description=${vendor_specific_service_api_description} ... vendor_specific_aef_profile=${vendor_specific_aef_profile} + ${resp}= Post Request Capif + ... /published-apis/v1/${register_user_info['apf_id']}/service-apis + ... json=${request_body} + ... server=${CAPIF_HTTPS_URL} + ... verify=ca.crt + ... username=${register_user_info['apf_username']} Check Response Variable Type And Values ... ${resp} @@ -283,10 +313,17 @@ Publish API without supportedFeatures # Register APF ${register_user_info}= Provider Default Registration - # Publish one api - ${service_api_description_published} ${resource_url} ${request_body}= Publish Service Api - ... ${register_user_info} + # Publish API without supported features + ${request_body}= Create Service Api Description + ... api_name=service_1 + ... aef_id=${register_user_info['aef_id']} ... supported_features=${NONE} + ${resp}= Post Request Capif + ... /published-apis/v1/${register_user_info['apf_id']}/service-apis + ... json=${request_body} + ... server=${CAPIF_HTTPS_URL} + ... verify=ca.crt + ... username=${register_user_info['apf_username']} Check Response Variable Type And Values ... ${resp} -- GitLab From f3f1740481b3fb092efd03e95cf02cf781775d15 Mon Sep 17 00:00:00 2001 From: Jorge Moratinos Salcines Date: Wed, 27 Nov 2024 10:54:51 +0100 Subject: [PATCH 6/8] Remove error on basicRequests --- tests/resources/common/basicRequests.robot | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/resources/common/basicRequests.robot b/tests/resources/common/basicRequests.robot index 58374be..b5c08c0 100644 --- a/tests/resources/common/basicRequests.robot +++ b/tests/resources/common/basicRequests.robot @@ -453,7 +453,7 @@ Delete User At Register ${resp}= Delete User Admin Register Request ${user_uuid} Should Be Equal As Strings ${resp.status_code} 204 -q + IF ${environment_users} Call Method ${CAPIF_USERS} remove_register_users_entry ${user_uuid} END -- GitLab From 89b6206c9ad12b342329b1673cb9bfe15502d82a Mon Sep 17 00:00:00 2001 From: Jorge Moratinos Salcines Date: Wed, 27 Nov 2024 11:18:02 +0100 Subject: [PATCH 7/8] Include vault requests --- tests/libraries/bodyRequests.py | 1 + tests/libraries/vault_requests/bodyRequests.py | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 tests/libraries/vault_requests/bodyRequests.py diff --git a/tests/libraries/bodyRequests.py b/tests/libraries/bodyRequests.py index 30597ba..4790e54 100644 --- a/tests/libraries/bodyRequests.py +++ b/tests/libraries/bodyRequests.py @@ -6,3 +6,4 @@ from api_events.bodyRequests import * from security_api.bodyRequests import * from api_provider_management.bodyRequests import * from vendor_extensibility.bodyRequests import * +from vault_requests.bodyRequests import * \ No newline at end of file diff --git a/tests/libraries/vault_requests/bodyRequests.py b/tests/libraries/vault_requests/bodyRequests.py new file mode 100644 index 0000000..3bade1a --- /dev/null +++ b/tests/libraries/vault_requests/bodyRequests.py @@ -0,0 +1,17 @@ +def sign_csr_body(username, public_key): + data = { + "csr": public_key.decode("utf-8"), + "mode": "client", + "filename": username + } + return data + + +def vault_sign_superadmin_certificate_body(csr_request): + data = { + "format": "pem_bundle", + "ttl": "43000h", + "csr": csr_request.decode("utf-8"), + "common_name": "superadmin" + } + return data -- GitLab From cf101ffce6f3ece47f19abccef94656fae60d01e Mon Sep 17 00:00:00 2001 From: Jorge Moratinos Salcines Date: Thu, 28 Nov 2024 11:54:17 +0100 Subject: [PATCH 8/8] Set default supportedFeatures to 0 --- tests/libraries/api_publish_service/bodyRequests.py | 2 +- tests/resources/common/basicRequests.robot | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/libraries/api_publish_service/bodyRequests.py b/tests/libraries/api_publish_service/bodyRequests.py index beeb225..ddf25ff 100644 --- a/tests/libraries/api_publish_service/bodyRequests.py +++ b/tests/libraries/api_publish_service/bodyRequests.py @@ -1,4 +1,4 @@ -def create_service_api_description(api_name="service_1", aef_id="aef_id", supported_features="fffff", vendor_specific_service_api_description=None, vendor_specific_aef_profile=None): +def create_service_api_description(api_name="service_1", aef_id="aef_id", supported_features="0", vendor_specific_service_api_description=None, vendor_specific_aef_profile=None): body = { "apiName": api_name, "aefProfiles": [ diff --git a/tests/resources/common/basicRequests.robot b/tests/resources/common/basicRequests.robot index 5327f39..1f69f48 100644 --- a/tests/resources/common/basicRequests.robot +++ b/tests/resources/common/basicRequests.robot @@ -792,7 +792,7 @@ Publish Service Api ... ${service_name}=service_1 ... ${apf_id}=${NONE} ... ${apf_username}=${NONE} - ... ${supported_features}=fffff + ... ${supported_features}=0 ... ${vendor_specific_service_api_description}=${None} ... ${vendor_specific_aef_profile}=${None} -- GitLab