diff --git a/services/TS29222_CAPIF_Publish_Service_API/published_apis/core/serviceapidescriptions.py b/services/TS29222_CAPIF_Publish_Service_API/published_apis/core/serviceapidescriptions.py index ad148367ead77aa6b9c42498d69609a211acb0dc..a7ea51318f55eecd3cb46b2256cb27c03626643a 100644 --- a/services/TS29222_CAPIF_Publish_Service_API/published_apis/core/serviceapidescriptions.py +++ b/services/TS29222_CAPIF_Publish_Service_API/published_apis/core/serviceapidescriptions.py @@ -58,26 +58,6 @@ def find_duplicate_service_by_api_name_and_aef( return collection.find_one(duplicate_query), aef_ids -def shared_capif_prov_doms(shareable_info): - """Return the CAPIF provider domains a service API is meant to be shared with.""" - shareable_info = shareable_info or {} - - if not shareable_info.get("is_shareable"): - return [] - - return shareable_info.get("capif_prov_doms") or [] - - -def interconnection_payload(service_api): - """Serialize a service API the way a peer CCF expects to receive it.""" - payload = { - key: value for key, value in service_api.items() - if key not in ("_id", "apf_id", "onboarding_date") - } - # The peer stores the service API as its own, it must not share it any further - payload["shareable_info"] = {"is_shareable": False} - - return json.dumps(clean_n_camel_case(payload), cls=encoder.CustomJSONEncoder) def return_negotiated_supp_feat_dict(supp_feat): @@ -216,7 +196,7 @@ class PublishServiceOperations(Resource): ) published, interconnection_error = self.publish_to_interconnected_ccfs( - rec, shared_capif_prov_doms(rec.get("shareable_info"))) + rec, self.shared_capif_prov_doms(rec.get("shareable_info"))) if interconnection_error is not None: # Nothing is stored here, so a copy left on a peer would be an orphan and @@ -424,7 +404,7 @@ class PublishServiceOperations(Resource): 'accept': 'application/json', 'Content-Type': 'application/json' } - body = interconnection_payload(service_api) + body = self.interconnection_payload(service_api) for dom in capif_prov_doms: if interconnected_col.find_one({"dst_prov_dom": dom}) is None: @@ -482,7 +462,7 @@ class PublishServiceOperations(Resource): 'accept': 'application/json', 'Content-Type': 'application/json' } - body = interconnection_payload(service_api) + body = self.interconnection_payload(service_api) published = [] for dom in capif_prov_doms: @@ -539,8 +519,8 @@ class PublishServiceOperations(Resource): store and an error response if any peer could not be aligned, in which case the caller must leave the service API untouched. """ - old_doms = shared_capif_prov_doms(old_service_api.get("shareable_info")) - new_doms = shared_capif_prov_doms(service_api.get("shareable_info")) + old_doms = self.shared_capif_prov_doms(old_service_api.get("shareable_info")) + new_doms = self.shared_capif_prov_doms(service_api.get("shareable_info")) pub_api_path = old_service_api.get("pub_api_path") if not old_doms and not new_doms: @@ -611,7 +591,7 @@ class PublishServiceOperations(Resource): # "_" contains the CCF ids where the API was successfully deleted _, interconnection_error = self.unpublish_from_interconnected_ccfs( serviceapidescription_dict.get("api_name"), - shared_capif_prov_doms(serviceapidescription_dict.get("shareable_info"))) + self.shared_capif_prov_doms(serviceapidescription_dict.get("shareable_info"))) if interconnection_error is not None: return interconnection_error @@ -949,3 +929,38 @@ class PublishServiceOperations(Resource): current_app.logger.debug("Service available") service_api_status = "SERVICE_API_AVAILABLE" return service_api_status + + def interconnection_payload(self, service_api): + """Serialize a service API the way a peer CCF expects to receive it.""" + payload = { + key: value for key, value in service_api.items() + if key not in ("_id", "apf_id", "onboarding_date") + } + # The peer stores the service API as its own, it must not share it any further + payload["shareable_info"] = {"is_shareable": False} + + # Publish between CCFs (Interface CAPIF-6 and CAPIF-6e) must include ccfId to contact when serviceAPICategory is used. + if service_api.get("service_api_category") is not None: + config_col = self.db.get_col_by_name(self.db.capif_configuration) + config = config_col.find_one({}, {"_id": 0}) + payload['ccf_id'] = config['ccf_id'] + + return json.dumps(clean_n_camel_case(payload), cls=encoder.CustomJSONEncoder) + + def shared_capif_prov_doms(self, shareable_info): + """Return the CAPIF provider domains a service API is meant to be shared with.""" + shareable_info = shareable_info or {} + + if not shareable_info.get("is_shareable"): + return [] + + capif_prov_doms = shareable_info.get("capif_prov_doms") + if capif_prov_doms is not None: + return capif_prov_doms + else: + interconnected_col = self.db.get_col_by_name(self.db.interconnected) + dst_prov_doms = interconnected_col.distinct("dst_prov_dom") + current_app.logger.debug(dst_prov_doms) + return dst_prov_doms + + # return shareable_info.get("capif_prov_doms") or [] \ No newline at end of file diff --git a/services/envs/dev1.env b/services/envs/dev1.env index adb5836e7b026f9e568a4887e6d0ac4910e49d77..0f6b052815ba48344e1609ea74ff3cc5abcc3b6b 100644 --- a/services/envs/dev1.env +++ b/services/envs/dev1.env @@ -1,5 +1,6 @@ export CAPIF_NETWORK_NAME=capif-network-a export COMPOSE_PROJECT_NAME=ocf_a +export CAPIF_INTERCONNECTION_HOSTNAME=capifcore-b # Capif vault configuration export CAPIF_VAULT_PORT=8200 diff --git a/services/envs/dev2.env b/services/envs/dev2.env index e80b476b566d952ed41cddd88272c2084a237464..cf68662b9c6bb3ae82073846ab489c78f296178f 100644 --- a/services/envs/dev2.env +++ b/services/envs/dev2.env @@ -1,5 +1,6 @@ export CAPIF_NETWORK_NAME=capif-network-b export COMPOSE_PROJECT_NAME=ocf_b +export CAPIF_INTERCONNECTION_HOSTNAME=capifcore-a # Capif vault configuration export DEPLOY_VAULT=false diff --git a/services/helper/helper_service/services/interconnection/core/ccfinstancedetails.py b/services/helper/helper_service/services/interconnection/core/ccfinstancedetails.py index ae5341b0f48197eadf238fce7ec2aab40aa09b54..dc6df6aae95d71ee2a545e2a64b69fc8fc0cd262 100644 --- a/services/helper/helper_service/services/interconnection/core/ccfinstancedetails.py +++ b/services/helper/helper_service/services/interconnection/core/ccfinstancedetails.py @@ -104,9 +104,13 @@ class CcfInstanceOperations(Resource): services_col = self.db.get_col_by_name(self.db.services_col) shareable_apis = services_col.find({ "shareable_info.is_shareable": True, - "shareable_info.capif_prov_doms": peer_dom, "apf_id": {"$ne": peer_ccf_id}, - "pub_api_path.ccf_ids": {"$ne": peer_ccf_id} + "pub_api_path.ccf_ids": {"$ne": peer_ccf_id}, + "$or": [ + {"shareable_info.capif_prov_doms": peer_dom}, + {"shareable_info.capif_prov_doms": {"$exists": False}}, + {"shareable_info.capif_prov_doms": None} + ] }) url = "https://{}/published-apis/v1/{}/service-apis".format(peer_dom, local_ccf_id) @@ -130,6 +134,10 @@ class CcfInstanceOperations(Resource): # The peer stores the API as its own, it must not share it any further payload['shareable_info'] = {"is_shareable": False} + # Publish between CCFs (Interface CAPIF-6 and CAPIF-6e) must include ccfId to contact when serviceAPICategory is used. + if service_api.get("service_api_category") is not None: + payload['ccf_id'] = local_ccf_id + try: response = session.post(url, data=json.dumps(clean_n_camel_case(payload), cls=CustomJSONEncoder), diff --git a/services/remove_users.sh b/services/remove_users.sh index 27cee230253b9cd9421d45728f12479d0f43437e..c22a22f914a5f1b4e0ce61657ab5f60627a48f56 100755 --- a/services/remove_users.sh +++ b/services/remove_users.sh @@ -119,4 +119,4 @@ docker run $DOCKER_ROBOT_TTY_OPTIONS --rm --network="host" \ --variable NOTIFICATION_DESTINATION_URL:$NOTIFICATION_DESTINATION_URL \ --variable MOCK_SERVER_URL:$MOCK_SERVER_URL \ --variable USERNAME_PREFIX:$USERNAME_PREFIX \ - --include remove-users + --include remove-users-by-prefix diff --git a/tests/features/CAPIF Api Invoker Management/capif_api_invoker_managenet.robot b/tests/features/CAPIF Api Invoker Management/capif_api_invoker_managenet.robot index 165fbed9a16a41e013699fcd53d5e05ffeb8e4b0..872b6003e19841db4fff0b6c7e3498f96c01b2c4 100644 --- a/tests/features/CAPIF Api Invoker Management/capif_api_invoker_managenet.robot +++ b/tests/features/CAPIF Api Invoker Management/capif_api_invoker_managenet.robot @@ -37,7 +37,7 @@ Onboard Network App # Check Results Check Response Variable Type And Values ${resp} 201 APIInvokerEnrolmentDetails ${url}= Parse Url ${resp.headers['Location']} - Call Method ${CAPIF_USERS} update_capif_users_dicts ${url.path} ${INVOKER_USERNAME} + Call Method ${CAPIF_USERS} update_capif_users_dicts ${url.path} ${INVOKER_USERNAME} ${CAPIF_HTTPS_URL} Check Location Header ${resp} ${LOCATION_INVOKER_RESOURCE_REGEX} # Store dummy signed certificate @@ -184,7 +184,7 @@ Update Onboarded Network App Certificate ... notificationDestination=${new_notification_destination} # Update CAPIF_USERS to use the NEW certificate name for cleanup - Call Method ${CAPIF_USERS} update_capif_users_dicts ${url.path} ${INVOKER_USERNAME_NEW} + Call Method ${CAPIF_USERS} update_capif_users_dicts ${url.path} ${INVOKER_USERNAME_NEW} ${CAPIF_HTTPS_URL} Onboard invoker without supported_features [Tags] capif_api_invoker_management-8 diff --git a/tests/features/CAPIF Api Provider Management/capif_api_provider_management.robot b/tests/features/CAPIF Api Provider Management/capif_api_provider_management.robot index cc8c9eb2995f95b38bb69b8e1bbe41ba6d0488fa..6111da1a1e008b33507ca998a5b45d6773c54392 100644 --- a/tests/features/CAPIF Api Provider Management/capif_api_provider_management.robot +++ b/tests/features/CAPIF Api Provider Management/capif_api_provider_management.robot @@ -52,7 +52,7 @@ Register Api Provider Check Response Variable Type And Values ${resp} 201 APIProviderEnrolmentDetails ${url}= Parse Url ${resp.headers['Location']} - Call Method ${CAPIF_USERS} update_capif_users_dicts ${url.path} ${register_user_info['amf_username']} + Call Method ${CAPIF_USERS} update_capif_users_dicts ${url.path} ${register_user_info['amf_username']} ${CAPIF_HTTPS_URL} ${resource_url}= Check Location Header ${resp} ${LOCATION_PROVIDER_RESOURCE_REGEX} diff --git a/tests/features/Helper/Interconnection API/interconnection.robot b/tests/features/Helper/Interconnection API/interconnection.robot index 06f27e36ec7c209a8c22fb041d82c183516aead7..86a3b40e3de7c2a3d939787b2a80f5b87a7950c4 100644 --- a/tests/features/Helper/Interconnection API/interconnection.robot +++ b/tests/features/Helper/Interconnection API/interconnection.robot @@ -19,8 +19,8 @@ ${SUBSCRIPTION_ID_NOT_VALID} not-valid *** Test Cases *** -Interconnection 2 CCF - [Tags] interconnection-1 +Interconnection Request between CCF-A and CCF-B + [Tags] interconnection-1 -all ${DESTINATION_PROVIDER_DOMAIN}= Set Variable capifcore-b:1443 @@ -48,37 +48,485 @@ Interconnection 2 CCF Should Be Equal As Integers ${resp.status_code} 204 -Interconnection 2 CCF X - [Tags] interconnection-2 +Interconnection Request between CCF-A and CCF-B with one API published on CCF-A capifProvDoms not present + [Tags] interconnection-2 -all - ${DESTINATION_PROVIDER_DOMAIN}= Set Variable capifcore-b:1443 + # Publish one api on CCF-A + ## 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} + ... is_shareable=${True} + + ## 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 + Log "API discovered by authorised API invoker at CCF-A" + 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} - ${ccf_id_a}= Get Capif Ccf Id - ${ccf_crt}= Read File Utf8 ${CCF_USERNAME}.crt - ${ccf_key}= Read File Utf8 ${CCF_USERNAME}.key - ${ccf_ca}= Read File Utf8 ${CCF_USERNAME}_ca.crt + # Interconnection Request between CCF-A and CCF-B + ${INTERCONNECTION_CCF_HOSTNAME}= Set Variable capifcore-b:1443 + ${INTERCONNECTION_CCF_REGISTER_HOSTNAME}= Set Variable register-b:8184 - ${body}= Create Connection Request Body - ... ${ccf_ca} - ... ${ccf_id_a} - ... ${DESTINATION_PROVIDER_DOMAIN} - ... ${ccf_crt} + Set Global Variable ${CAPIF_HTTPS_URL_B} https://${INTERCONNECTION_CCF_HOSTNAME}/ + Set Global Variable ${CAPIF_HTTPS_REGISTER_URL_B} https://${INTERCONNECTION_CCF_REGISTER_HOSTNAME}/ + + ${ccf_id_a}= Get Capif Ccf Id + + ${body}= Create Interconnection Request Body ${INTERCONNECTION_CCF_HOSTNAME} ${resp}= Post Request Capif - ... /helper/interconnection/establish + ... /helper/interconnection/request ... server=${CAPIF_HTTPS_URL} ... verify=ca.crt - ... username=${CCF_USERNAME} + ... username=${SUPERADMIN_USERNAME} ... json=${body} Should Be Equal As Integers ${resp.status_code} 201 Log Dictionary ${resp.json()} + ${ccf_id_b}= Set Variable ${resp.json()['ccfId']} - # Delete interconnection - ${resp}= Delete Request Capif - ... /helper/interconnection/establish/${ccf_id_a} + Call Method ${CAPIF_USERS} update_ccf_interconnected ${CAPIF_HTTPS_URL} ${ccf_id_b} ${SUPERADMIN_USERNAME} + + ## Default Invoker Registration and Onboarding + ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding + ... invoker_username=${INVOKER_USERNAME}_B + ... register_server=${CAPIF_HTTPS_REGISTER_URL_B} + ... capif_server=${CAPIF_HTTPS_URL_B} + + ## 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_B} + ... verify=ca.crt + ... username=${INVOKER_USERNAME}_B + + Check Response Variable Type And Values ${resp} 200 DiscoveredAPIs + Should Not Be Empty ${resp.json()['serviceAPIDescriptions']} + Length Should Be ${resp.json()['serviceAPIDescriptions']} 1 + Should Not Be Empty ${resp.json()['serviceAPIDescriptions'][0]['pubApiPath']} + Length Should Be ${resp.json()['serviceAPIDescriptions'][0]['pubApiPath']['ccfIds']} 1 + List Should Contain Value ${resp.json()['serviceAPIDescriptions'][0]['pubApiPath']['ccfIds']} ${ccf_id_a} + +Interconnection Request between CCF-A and CCF-B with one API published on CCF-A capifProvDoms present with CCF-B hostname + [Tags] interconnection-3 -all + + # Interconnection Request between CCF-A and CCF-B + ${INTERCONNECTION_CCF_HOSTNAME}= Set Variable capifcore-b:1443 + ${INTERCONNECTION_CCF_REGISTER_HOSTNAME}= Set Variable register-b:8184 + + Set Global Variable ${CAPIF_HTTPS_URL_B} https://${INTERCONNECTION_CCF_HOSTNAME}/ + Set Global Variable ${CAPIF_HTTPS_REGISTER_URL_B} https://${INTERCONNECTION_CCF_REGISTER_HOSTNAME}/ + + + # ${hostname_parsed}= Parse Url ${INTERCONNECTION_CCF_HOSTNAME} + # ${ccf_hostname}= Set Variable ${hostname_parsed.hostname} + + ${ccf_id_a}= Get Capif Ccf Id + + + # Publish one api on CCF-A + ## 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} + ... is_shareable=${True} + ... capif_prov_doms=${INTERCONNECTION_CCF_HOSTNAME} + + ## 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=${CCF_USERNAME} + ... username=${INVOKER_USERNAME} - Should Be Equal As Integers ${resp.status_code} 204 + Check Response Variable Type And Values ${resp} 200 DiscoveredAPIs + + # Check Results + Log "API discovered by authorised API invoker at CCF-A" + 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} + + # Request interconnection between CCF-A and CCF-B + ${resp}= Create Capif Interconnection server=${CAPIF_HTTPS_URL} ccf_hostname=${INTERCONNECTION_CCF_HOSTNAME} superadmin_username=${SUPERADMIN_USERNAME} + ${ccf_id_b}= Set Variable ${resp.json()['ccfId']} + + ## Default Invoker Registration and Onboarding + ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding + ... invoker_username=${INVOKER_USERNAME}_B + ... register_server=${CAPIF_HTTPS_REGISTER_URL_B} + ... capif_server=${CAPIF_HTTPS_URL_B} + + ## 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_B} + ... verify=ca.crt + ... username=${INVOKER_USERNAME}_B + + Check Response Variable Type And Values ${resp} 200 DiscoveredAPIs + Should Not Be Empty ${resp.json()['serviceAPIDescriptions']} + Length Should Be ${resp.json()['serviceAPIDescriptions']} 1 + Should Not Be Empty ${resp.json()['serviceAPIDescriptions'][0]['pubApiPath']} + Length Should Be ${resp.json()['serviceAPIDescriptions'][0]['pubApiPath']['ccfIds']} 1 + List Should Contain Value ${resp.json()['serviceAPIDescriptions'][0]['pubApiPath']['ccfIds']} ${ccf_id_a} + + +Interconnection Request between CCF-A and CCF-B with one API published on CCF-A capifProvDoms present with OTHER hostname + [Tags] interconnection-4 -all + + # Interconnection Request between CCF-A and CCF-B + ${INTERCONNECTION_CCF_HOSTNAME}= Set Variable capifcore-b:1443 + ${INTERCONNECTION_CCF_REGISTER_HOSTNAME}= Set Variable register-b:8184 + + Set Global Variable ${CAPIF_HTTPS_URL_B} https://${INTERCONNECTION_CCF_HOSTNAME}/ + Set Global Variable ${CAPIF_HTTPS_REGISTER_URL_B} https://${INTERCONNECTION_CCF_REGISTER_HOSTNAME}/ + + # Publish one api on CCF-A + ## 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} + ... is_shareable=${True} + ... capif_prov_doms=OTHER + + ## 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 + Log "API discovered by authorised API invoker at CCF-A" + 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} + + # Request interconnection between CCF-A and CCF-B + ${resp}= Create Capif Interconnection server=${CAPIF_HTTPS_URL} ccf_hostname=${INTERCONNECTION_CCF_HOSTNAME} superadmin_username=${SUPERADMIN_USERNAME} + ${ccf_id_b}= Set Variable ${resp.json()['ccfId']} + + ## Default Invoker Registration and Onboarding + ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding + ... invoker_username=${INVOKER_USERNAME}_B + ... register_server=${CAPIF_HTTPS_REGISTER_URL_B} + ... capif_server=${CAPIF_HTTPS_URL_B} + + ## 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_B} + ... verify=ca.crt + ... username=${INVOKER_USERNAME}_B + + 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 after CAPIFs Interconnection with capifProvDoms present with CCF-B hostname + [Tags] interconnection-5 -all + + ${ccf_id_a}= Get Capif Ccf Id + + # Interconnection Request between CCF-A and CCF-B + ${INTERCONNECTION_CCF_HOSTNAME}= Set Variable capifcore-b:1443 + ${INTERCONNECTION_CCF_REGISTER_HOSTNAME}= Set Variable register-b:8184 + + Set Global Variable ${CAPIF_HTTPS_URL_B} https://${INTERCONNECTION_CCF_HOSTNAME}/ + Set Global Variable ${CAPIF_HTTPS_REGISTER_URL_B} https://${INTERCONNECTION_CCF_REGISTER_HOSTNAME}/ + + # Request interconnection between CCF-A and CCF-B + ${resp}= Create Capif Interconnection server=${CAPIF_HTTPS_URL} ccf_hostname=${INTERCONNECTION_CCF_HOSTNAME} superadmin_username=${SUPERADMIN_USERNAME} + ${ccf_id_b}= Set Variable ${resp.json()['ccfId']} + + # Publish one api on CCF-A + ## 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} + ... is_shareable=${True} + ... capif_prov_doms=${INTERCONNECTION_CCF_HOSTNAME} + + ## Default Invoker Registration and Onboarding + ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding + ... invoker_username=${INVOKER_USERNAME}_B + ... register_server=${CAPIF_HTTPS_REGISTER_URL_B} + ... capif_server=${CAPIF_HTTPS_URL_B} + + ## 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_B} + ... verify=ca.crt + ... username=${INVOKER_USERNAME}_B + + Check Response Variable Type And Values ${resp} 200 DiscoveredAPIs + Should Not Be Empty ${resp.json()['serviceAPIDescriptions']} + Length Should Be ${resp.json()['serviceAPIDescriptions']} 1 + Should Not Be Empty ${resp.json()['serviceAPIDescriptions'][0]['pubApiPath']} + Length Should Be ${resp.json()['serviceAPIDescriptions'][0]['pubApiPath']['ccfIds']} 1 + List Should Contain Value ${resp.json()['serviceAPIDescriptions'][0]['pubApiPath']['ccfIds']} ${ccf_id_a} + +Publish API after CAPIFs Interconnection with capifProvDoms not present + [Tags] interconnection-6 -all + + ${ccf_id_a}= Get Capif Ccf Id + + # Interconnection Request between CCF-A and CCF-B + ${INTERCONNECTION_CCF_HOSTNAME}= Set Variable capifcore-b:1443 + ${INTERCONNECTION_CCF_REGISTER_HOSTNAME}= Set Variable register-b:8184 + + Set Global Variable ${CAPIF_HTTPS_URL_B} https://${INTERCONNECTION_CCF_HOSTNAME}/ + Set Global Variable ${CAPIF_HTTPS_REGISTER_URL_B} https://${INTERCONNECTION_CCF_REGISTER_HOSTNAME}/ + + # Request interconnection between CCF-A and CCF-B + ${resp}= Create Capif Interconnection server=${CAPIF_HTTPS_URL} ccf_hostname=${INTERCONNECTION_CCF_HOSTNAME} superadmin_username=${SUPERADMIN_USERNAME} + ${ccf_id_b}= Set Variable ${resp.json()['ccfId']} + + # Publish one api on CCF-A + ## 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} + ... is_shareable=${True} + + ## Default Invoker Registration and Onboarding + ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding + ... invoker_username=${INVOKER_USERNAME}_B + ... register_server=${CAPIF_HTTPS_REGISTER_URL_B} + ... capif_server=${CAPIF_HTTPS_URL_B} + + ## 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_B} + ... verify=ca.crt + ... username=${INVOKER_USERNAME}_B + + Check Response Variable Type And Values ${resp} 200 DiscoveredAPIs + Should Not Be Empty ${resp.json()['serviceAPIDescriptions']} + Length Should Be ${resp.json()['serviceAPIDescriptions']} 1 + Should Not Be Empty ${resp.json()['serviceAPIDescriptions'][0]['pubApiPath']} + Length Should Be ${resp.json()['serviceAPIDescriptions'][0]['pubApiPath']['ccfIds']} 1 + List Should Contain Value ${resp.json()['serviceAPIDescriptions'][0]['pubApiPath']['ccfIds']} ${ccf_id_a} + + + +Interconnection Request between CCF-A and CCF-B with one API published on CCF-B capifProvDoms not present + [Tags] interconnection-7 -all + + # Interconnection Request between CCF-A and CCF-B + ${INTERCONNECTION_CCF_HOSTNAME}= Set Variable capifcore-b:1443 + ${INTERCONNECTION_CCF_REGISTER_HOSTNAME}= Set Variable register-b:8184 + + Set Global Variable ${CAPIF_HTTPS_URL_B} https://${INTERCONNECTION_CCF_HOSTNAME}/ + Set Global Variable ${CAPIF_HTTPS_REGISTER_URL_B} https://${INTERCONNECTION_CCF_REGISTER_HOSTNAME}/ + + ${provider_username_b}= Set Variable ${provider_username}_B + + # Publish one api on CCF-A + ## Register APF + ${register_user_info}= Provider Default Registration register_server=${CAPIF_HTTPS_REGISTER_URL_B} capif_server=${CAPIF_HTTPS_URL_B} provider_username=${provider_username_b} + + ## Publish one api + ${service_api_description_published} ${resource_url} ${request_body}= Publish Service Api + ... ${register_user_info} + ... is_shareable=${True} + ... server=${CAPIF_HTTPS_URL_B} + + ${ccf_id_a}= Get Capif Ccf Id + + # Request interconnection between CCF-A and CCF-B + ${resp}= Create Capif Interconnection server=${CAPIF_HTTPS_URL} ccf_hostname=${INTERCONNECTION_CCF_HOSTNAME} superadmin_username=${SUPERADMIN_USERNAME} + ${ccf_id_b}= Set Variable ${resp.json()['ccfId']} + + ## Default Invoker Registration and Onboarding + ${register_user_info_invoker_b} ${url} ${request_body}= Invoker Default Onboarding + ... invoker_username=${INVOKER_USERNAME}_B + ... register_server=${CAPIF_HTTPS_REGISTER_URL_B} + ... capif_server=${CAPIF_HTTPS_URL_B} + + ## Test + ${resp}= Get Request Capif + ... ${DISCOVER_URL}${register_user_info_invoker_b['api_invoker_id']}&aef-id=${register_user_info['aef_id']} + ... server=${CAPIF_HTTPS_URL_B} + ... verify=ca.crt + ... username=${INVOKER_USERNAME}_B + + Check Response Variable Type And Values ${resp} 200 DiscoveredAPIs + Should Not Be Empty ${resp.json()['serviceAPIDescriptions']} + Length Should Be ${resp.json()['serviceAPIDescriptions']} 1 + # Dictionary Should Not Contain Key ${resp.json()['serviceAPIDescriptions'][0]} pubApiPath + # List Should Contain Value ${resp.json()['serviceAPIDescriptions'][0]['pubApiPath']['ccfIds']} ${ccf_id_b} + + ## Default Invoker Registration and Onboarding + ${register_user_info_invoker_a} ${url} ${request_body}= Invoker Default Onboarding + + ## Test + ${resp}= Get Request Capif + ... ${DISCOVER_URL}${register_user_info_invoker_a['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 + Log "API discovered by authorised API invoker at CCF-A" + Should Not Be Empty ${resp.json()['serviceAPIDescriptions']} + Length Should Be ${resp.json()['serviceAPIDescriptions']} 1 + # Should Not Be Empty ${resp.json()['serviceAPIDescriptions'][0]['pubApiPath']} + # Length Should Be ${resp.json()['serviceAPIDescriptions'][0]['pubApiPath']['ccfIds']} 1 + # List Should Contain Value ${resp.json()['serviceAPIDescriptions'][0]['pubApiPath']['ccfIds']} ${ccf_id_b} + + + +Publish API at CCF_B after CAPIFs Interconnection with capifProvDoms not present + [Tags] interconnection-8 -all + + # Interconnection Request between CCF-A and CCF-B + ${INTERCONNECTION_CCF_HOSTNAME}= Set Variable capifcore-b:1443 + ${INTERCONNECTION_CCF_REGISTER_HOSTNAME}= Set Variable register-b:8184 + + Set Global Variable ${CAPIF_HTTPS_URL_B} https://${INTERCONNECTION_CCF_HOSTNAME}/ + Set Global Variable ${CAPIF_HTTPS_REGISTER_URL_B} https://${INTERCONNECTION_CCF_REGISTER_HOSTNAME}/ + + ${provider_username_b}= Set Variable ${provider_username}_B + + ${ccf_id_a}= Get Capif Ccf Id + + # Request interconnection between CCF-A and CCF-B + ${resp}= Create Capif Interconnection server=${CAPIF_HTTPS_URL} ccf_hostname=${INTERCONNECTION_CCF_HOSTNAME} superadmin_username=${SUPERADMIN_USERNAME} + ${ccf_id_b}= Set Variable ${resp.json()['ccfId']} + + # Publish one api on CCF-B + ## Register APF + ${register_user_info}= Provider Default Registration register_server=${CAPIF_HTTPS_REGISTER_URL_B} capif_server=${CAPIF_HTTPS_URL_B} provider_username=${provider_username_b} + + ## Publish one api + ${service_api_description_published} ${resource_url} ${request_body}= Publish Service Api + ... ${register_user_info} + ... is_shareable=${True} + ... server=${CAPIF_HTTPS_URL_B} + + ## Default Invoker Registration and Onboarding + ${register_user_info_invoker_b} ${url} ${request_body}= Invoker Default Onboarding + ... invoker_username=${INVOKER_USERNAME}_B + ... register_server=${CAPIF_HTTPS_REGISTER_URL_B} + ... capif_server=${CAPIF_HTTPS_URL_B} + + ## Test + ${resp}= Get Request Capif + ... ${DISCOVER_URL}${register_user_info_invoker_b['api_invoker_id']}&aef-id=${register_user_info['aef_id']} + ... server=${CAPIF_HTTPS_URL_B} + ... verify=ca.crt + ... username=${INVOKER_USERNAME}_B + + Check Response Variable Type And Values ${resp} 200 DiscoveredAPIs + Should Not Be Empty ${resp.json()['serviceAPIDescriptions']} + Length Should Be ${resp.json()['serviceAPIDescriptions']} 1 + # Should Not Be Empty ${resp.json()['serviceAPIDescriptions'][0]['pubApiPath']} + # Length Should Be ${resp.json()['serviceAPIDescriptions'][0]['pubApiPath']['ccfIds']} 1 + # List Should Contain Value ${resp.json()['serviceAPIDescriptions'][0]['pubApiPath']['ccfIds']} ${ccf_id_b} + + ## Default Invoker Registration and Onboarding + ${register_user_info_invoker_a} ${url} ${request_body}= Invoker Default Onboarding + + ## Test + ${resp}= Get Request Capif + ... ${DISCOVER_URL}${register_user_info_invoker_a['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 + Log "API discovered by authorised API invoker at CCF-A" + Should Not Be Empty ${resp.json()['serviceAPIDescriptions']} + Length Should Be ${resp.json()['serviceAPIDescriptions']} 1 + Should Not Be Empty ${resp.json()['serviceAPIDescriptions'][0]['pubApiPath']} + # Length Should Be ${resp.json()['serviceAPIDescriptions'][0]['pubApiPath']['ccfIds']} 2 + # List Should Contain Value ${resp.json()['serviceAPIDescriptions'][0]['pubApiPath']['ccfIds']} ${ccf_id_b} + # List Should Contain Value ${resp.json()['serviceAPIDescriptions'][0]['pubApiPath']['ccfIds']} ${ccf_id_a} + + + + + +# Interconnection establish between CCF-A and CCF-B +# [Tags] interconnection-10 + +# ${DESTINATION_PROVIDER_DOMAIN}= Set Variable capifcore-b:1443 + +# ${ccf_id_a}= Get Capif Ccf Id + +# ${ccf_crt}= Read File Utf8 ${CCF_USERNAME}.crt +# ${ccf_key}= Read File Utf8 ${CCF_USERNAME}.key +# ${ccf_ca}= Read File Utf8 ${CCF_USERNAME}_ca.crt + +# ${body}= Create Connection Request Body +# ... ${ccf_ca} +# ... ${ccf_id_a} +# ... ${DESTINATION_PROVIDER_DOMAIN} +# ... ${ccf_crt} +# ${resp}= Post Request Capif +# ... /helper/interconnection/establish +# ... server=${CAPIF_HTTPS_URL} +# ... verify=ca.crt +# ... username=${CCF_USERNAME} +# ... json=${body} + +# Should Be Equal As Integers ${resp.status_code} 201 +# Log Dictionary ${resp.json()} + +# # Delete interconnection +# ${resp}= Delete Request Capif +# ... /helper/interconnection/establish/${ccf_id_a} +# ... server=${CAPIF_HTTPS_URL} +# ... verify=ca.crt +# ... username=${CCF_USERNAME} + +# Should Be Equal As Integers ${resp.status_code} 204 diff --git a/tests/libraries/api_publish_service/bodyRequests.py b/tests/libraries/api_publish_service/bodyRequests.py index 5f969a548f9fa8e5dd578933dc97f3e92610ae63..7daeb1c4c979dae353c6e49cb660215604521c1a 100644 --- a/tests/libraries/api_publish_service/bodyRequests.py +++ b/tests/libraries/api_publish_service/bodyRequests.py @@ -6,7 +6,12 @@ def create_service_api_description(api_name="service_1", api_status=None, security_methods="default", domain_name=None, - interface_descriptions=None): + interface_descriptions=None, + is_shareable=None, + capif_prov_doms=None, + service_api_category=None, + pub_api_path_ccf_ids=None, + ccf_id=None): aef_ids = list() if isinstance(aef_id, list): aef_ids = aef_id @@ -47,20 +52,7 @@ def create_service_api_description(api_name="service_1", "apiName": api_name, "aefProfiles": profiles, "description": "ROBOT_TESTING", - "shareableInfo": { - "isShareable": True, - "capifProvDoms": [ - "string" - ] - }, - "serviceAPICategory": "string", - "apiSuppFeats": "fffff", - "pubApiPath": { - "ccfIds": [ - "string" - ] - }, - "ccfId": "string" + "apiSuppFeats": "fffff" } if vendor_specific_service_api_description is not None: @@ -84,6 +76,31 @@ def create_service_api_description(api_name="service_1", body['apiStatus'] = dict() body['apiStatus']['aefIds'] = aef_ids_active + # shareable info + if is_shareable is not None: + body['shareableInfo'] = dict() + print(f"Setting isShareable to {is_shareable}") + body['shareableInfo']['isShareable'] = is_shareable + if capif_prov_doms is not None: + print(f"Setting capifProvDoms to {capif_prov_doms}") + if isinstance(capif_prov_doms, list): + body['shareableInfo']['capifProvDoms'] = capif_prov_doms + elif isinstance(capif_prov_doms, str): + body['shareableInfo']['capifProvDoms'] = [capif_prov_doms] + + if service_api_category is not None: + body['serviceAPICategory'] = service_api_category + + if pub_api_path_ccf_ids is not None: + body['pubApiPath'] = dict() + if isinstance(pub_api_path_ccf_ids, list): + body['pubApiPath']['ccfIds'] = pub_api_path_ccf_ids + elif isinstance(pub_api_path_ccf_ids, str): + body['pubApiPath']['ccfIds'] = [pub_api_path_ccf_ids] + + if ccf_id is not None: + body['ccfId'] = ccf_id + return body @@ -171,7 +188,6 @@ def create_aef_profile(aef_id, def create_service_api_description_patch(aef_id=None, description=None, - shareable_info=None, api_status=None, service_api_category=None, api_supp_feats=None, @@ -179,7 +195,9 @@ def create_service_api_description_patch(aef_id=None, ccf_id=None, security_methods=None, domain_name=None, - interface_descriptions=None): + interface_descriptions=None, + is_shareable=None, + capif_prov_doms=None): body = dict() # aef profiles @@ -219,8 +237,14 @@ def create_service_api_description_patch(aef_id=None, body['description'] = description # shareable info - if shareable_info is not None: - body['shareableInfo'] = shareable_info + if is_shareable is not None: + body['shareableInfo'] = dict() + body['shareableInfo']['isShareable'] = is_shareable + if capif_prov_doms is not None: + if isinstance(capif_prov_doms, list): + body['shareableInfo']['capifProvDoms'] = capif_prov_doms + elif isinstance(capif_prov_doms, str): + body['shareableInfo']['capifProvDoms'] = [capif_prov_doms] # service API Category if service_api_category is not None: diff --git a/tests/libraries/environment.py b/tests/libraries/environment.py index 0cb833e8d4c6c16d836579bc5843a2adb6c5f22f..805837fc87568df32badc2d67536249d3a7eae65 100644 --- a/tests/libraries/environment.py +++ b/tests/libraries/environment.py @@ -2,33 +2,75 @@ class CapifUserManager(): def __init__(self): self.capif_users = {} self.register_users = {} + self.interconnected_ccfs = {} - def update_register_users(self, uuid, username): - self.register_users[uuid] = username + def update_register_users(self, uuid, username, server): + self.register_users[uuid] = { + "username": username, + "server": server + } - def update_capif_users_dicts(self, key, value): - self.capif_users[key] = value + def update_capif_users_dicts(self, + resource_url_path, + management_certificate, + server): + self.capif_users[resource_url_path] = { + "management_certificate": management_certificate, + "server": server + } + + def update_ccf_interconnected(self, + ccf_hostname, + ccf_id, + username): + ccf_input = self.interconnected_ccfs.get(ccf_hostname) + if ccf_input is None: + ccf_interconnected = { + "hostname": ccf_hostname, + "ccf_ids_interconnected": [ccf_id], + "username": username + } + else: + ccf_interconnected = ccf_input + ccf_interconnected["ccf_ids_interconnected"].append(ccf_id) + self.interconnected_ccfs[ccf_hostname] = ccf_interconnected def remove_capif_users_entry(self, key): self.capif_users.pop(key) def remove_register_users_entry(self, uuid=None, username=None): - if uuid != None: + if uuid is not None: self.register_users.pop(uuid) - elif username != None: - uuid=self.get_user_uuid(username) + elif username is not None: + uuid, server = self.get_user_uuid(username) self.register_users.pop(uuid) + def remove_ccf_interconnected_entry(self, ccf_hostname): + self.interconnected_ccfs.pop(ccf_hostname) + + def remove_ccf_interconnected_entry_by_id(self, ccf_hostname, ccf_id): + ccf_input = self.interconnected_ccfs.get(ccf_hostname) + if ccf_input is not None: + ccf_interconnected = ccf_input + if ccf_id in ccf_interconnected["ccf_ids_interconnected"]: + ccf_interconnected["ccf_ids_interconnected"].remove(ccf_id) + self.interconnected_ccfs[ccf_hostname] = ccf_interconnected + if len(ccf_interconnected["ccf_ids_interconnected"]) == 0: + self.interconnected_ccfs.pop(ccf_hostname) + def get_capif_users_dict(self): return self.capif_users def get_register_users_dict(self): return self.register_users - + def get_user_uuid(self, username): - for uuid, stored_user in self.register_users.items(): - if stored_user == username: - return uuid - return None + for uuid, stored_user_info in self.register_users.items(): + if stored_user_info["username"] == username: + return uuid, stored_user_info["server"] + return None, None + + def get_ccf_interconnected_dict(self): + return self.interconnected_ccfs CAPIF_USERS = CapifUserManager() \ No newline at end of file diff --git a/tests/resources/common.resource b/tests/resources/common.resource index ac5a61d59911ea4207141c3c87b9821bc848da3f..f92ac459c9d7ff0591c0c6f4f8279f3b5ed1ffc0 100644 --- a/tests/resources/common.resource +++ b/tests/resources/common.resource @@ -55,12 +55,16 @@ Reset Testing Environment Check Location Header [Documentation] This keyword will check location header at response according to regular expression provided as argument - [Arguments] ${resp} ${regular_expression} + [Arguments] ${resp} ${regular_expression} ${hostname}=${CAPIF_HTTPS_URL} ${event_url}= Parse Url ${resp.headers['Location']} Should Match Regexp ${event_url.path} ${regular_expression} - Should Match Regexp ${event_url.netloc} ^${CAPIF_HOSTNAME}(:[0-9]+)?$ + + ${hostname_url}= Parse Url ${hostname} + + Should Match Regexp ${event_url.netloc} ^${hostname_url.hostname}(:[0-9]+)?$ + RETURN ${event_url} Check Event Location Header diff --git a/tests/resources/common/basicRequests.robot b/tests/resources/common/basicRequests.robot index f328094b8a6c7e88ac55cc7d010d65324224fbc2..84e92a6db759f28f7b610f22b37a7d8c9e532255 100644 --- a/tests/resources/common/basicRequests.robot +++ b/tests/resources/common/basicRequests.robot @@ -141,8 +141,10 @@ Get Request Admin Register RETURN ${resp} Delete User Admin Register Request - [Arguments] ${user_uuid} - ${headers}= Create Register Admin Session ${CAPIF_HTTPS_REGISTER_URL} verify=False + [Arguments] + ... ${user_uuid} + ... ${server}=${NONE} + ${headers}= Create Register Admin Session ${server} verify=False ${resp}= DELETE On Session register_session /deleteUser/${user_uuid} headers=${headers} RETURN ${resp} @@ -374,7 +376,12 @@ Delete Request Capif RETURN ${resp} Register User At Jwt Auth - [Arguments] ${username} ${role} ${password}=password ${description}=Testing + [Arguments] + ... ${username} + ... ${role} + ... ${password}=password + ... ${description}=Testing + ... ${server}=${CAPIF_HTTPS_REGISTER_URL} ${cn}= Set Variable ${username} # Create certificate and private_key for this machine. @@ -393,6 +400,7 @@ Register User At Jwt Auth ... ${password} ... ${description} ... email="${username}@nobody.com" + ... server=${server} ${get_auth_response}= Get Auth For User ${username} ${password} @@ -417,7 +425,7 @@ Register User At Jwt Auth Store In File ${username}.key ${register_user_info['private_key']} END - Call Method ${CAPIF_USERS} update_register_users ${register_user_info['uuid']} ${username} + # Call Method ${CAPIF_USERS} update_register_users ${register_user_info['uuid']} ${username} ${server} RETURN ${register_user_info} @@ -429,6 +437,7 @@ Register User At Jwt Auth Provider ... ${total_apf_roles}=1 ... ${total_aef_roles}=1 ... ${total_amf_roles}=1 + ... ${server}=${CAPIF_HTTPS_REGISTER_URL} ${apf_roles}= Create Dictionary ${default_apf_username}= Set Variable APF_${username} @@ -487,6 +496,7 @@ Register User At Jwt Auth Provider ... ${password} ... ${description} ... email="${username}@nobody.com" + ... server=${server} ${get_auth_response}= Get Auth For User ${username} ${password} @@ -509,20 +519,21 @@ Register User At Jwt Auth Provider Log Dictionary ${register_user_info} - Call Method ${CAPIF_USERS} update_register_users ${register_user_info['uuid']} ${username} + # Call Method ${CAPIF_USERS} update_register_users ${register_user_info['uuid']} ${username} ${server} RETURN ${register_user_info} -Login Register Admin - ${headers}= Create Register Admin Session ${CAPIF_HTTPS_REGISTER_URL} - RETURN ${headers} - Create User At Register [Documentation] (Administrator) This Keyword create a user at register component. - [Arguments] ${username} ${password} ${description} ${email} + [Arguments] + ... ${username} + ... ${password} + ... ${description} + ... ${email} + ... ${server}=${NONE} # Obtain Admin Token to request creation of User - ${headers}= Login Register Admin + ${headers}= Create Register Admin Session ${server} &{body}= Create Dictionary ... username=${username} @@ -537,24 +548,32 @@ Create User At Register ${resp}= Post On Session register_session /createUser headers=${headers} json=${body} Should Be Equal As Strings ${resp.status_code} 201 + Call Method ${CAPIF_USERS} update_register_users ${resp.json()['uuid']} ${username} ${server} + RETURN ${resp} Delete User At Register [Documentation] (Administrator) This Keyword delete a user from register. - [Arguments] ${username}=${NONE} ${uuid}=${NONE} + [Arguments] + ... ${username}=${NONE} + ... ${uuid}=${NONE} + ... ${server}=${CAPIF_HTTPS_REGISTER_URL} + ${user_uuid}= Set Variable ${uuid} ${environment_users}= Set Variable ${TRUE} + ${register_server}= Set Variable ${server} IF "${username}" != "${NONE}" - ${user_uuid}= Call Method ${CAPIF_USERS} get_user_uuid ${username} + ${user_uuid} ${register_server} = Call Method ${CAPIF_USERS} get_user_uuid ${username} END IF "${user_uuid}" == "${NONE}" ${user_uuid}= Get User Uuid At Register ${username} ${environment_users}= Set Variable ${FALSE} + ${register_server}= Set Variable ${CAPIF_HTTPS_REGISTER_URL} END - ${resp}= Delete User Admin Register Request ${user_uuid} + ${resp}= Delete User Admin Register Request ${user_uuid} server=${register_server} Should Be Equal As Strings ${resp.status_code} 204 @@ -566,7 +585,9 @@ Delete User At Register Get List of Users At Register [Documentation] (Administrator) This Keyword retrieve a list of users from register. - ${headers}= Create Register Admin Session ${CAPIF_HTTPS_REGISTER_URL} verify=False + [Arguments] ${server}=${NONE} + + ${headers}= Create Register Admin Session ${server} verify=False ${resp}= GET On Session register_session /getUsers headers=${headers} @@ -576,8 +597,11 @@ Get List of Users At Register Get User Uuid At Register [Documentation] (Administrator) This Keyword retrieve a list of users and search uuid of user passed by parameters - [Arguments] ${username} - ${users}= Get List of Users At Register + [Arguments] + ... ${username} + ... ${server}=${CAPIF_HTTPS_REGISTER_URL} + + ${users}= Get List of Users At Register ${server} # Find the first user with username indicated ${user_uuid}= Set Variable &{EMPTY} @@ -606,28 +630,48 @@ Get Auth For User RETURN ${resp.json()} Clean Test Information - ${capif_users_dict}= Call Method ${CAPIF_USERS} get_capif_users_dict - ${register_users_dict}= Call Method ${CAPIF_USERS} get_register_users_dict + # Remove all resources created during test execution at CAPIF + ${capif_users_dict}= Call Method ${CAPIF_USERS} get_capif_users_dict ${keys}= Get Dictionary Keys ${capif_users_dict} FOR ${key} IN @{keys} ${value}= Get From Dictionary ${capif_users_dict} ${key} + ${certificate_name}= Get From Dictionary ${value} management_certificate + ${server}= Get From Dictionary ${value} server ${resp}= Delete Request Capif ... ${key} - ... server=${CAPIF_HTTPS_URL} + ... server=${server} ... verify=ca.crt - ... username=${value} + ... username=${certificate_name} Status Should Be 204 ${resp} Call Method ${CAPIF_USERS} remove_capif_users_entry ${key} END + # Remove all users created during test execution at Register + ${register_users_dict}= Call Method ${CAPIF_USERS} get_register_users_dict + + Log Dictionary ${register_users_dict} + ${uuids}= Get Dictionary Keys ${register_users_dict} FOR ${uuid} IN @{uuids} - Delete User At Register uuid=${uuid} + ${user}= Get From Dictionary ${register_users_dict} ${uuid} + ${server}= Get From Dictionary ${user} server + Delete User At Register uuid=${uuid} server=${server} + END + + ${interconnected_users_dict}= Call Method ${CAPIF_USERS} get_ccf_interconnected_dict + ${ccf_hostnames}= Get Dictionary Keys ${interconnected_users_dict} + FOR ${ccf_hostname} IN @{ccf_hostnames} + ${ccf_interconnected}= Get From Dictionary ${interconnected_users_dict} ${ccf_hostname} + ${ccf_ids}= Get From Dictionary ${ccf_interconnected} ccf_ids_interconnected + ${username}= Get From Dictionary ${ccf_interconnected} username + FOR ${ccf_id} IN @{ccf_ids} + ${resp}= Remove Capif Interconnection ${ccf_hostname} ${ccf_id} ${username} + END END Remove entity @@ -643,12 +687,14 @@ Remove entity FOR ${key} IN @{keys} ${value}= Get From Dictionary ${capif_users_dict} ${key} - IF "${value}" == "${certificate_name}" + ${certificate_name}= Get From Dictionary ${value} management_certificate + ${server}= Get From Dictionary ${value} server + IF "${certificate_name}" == "${entity_user}" ${resp}= Delete Request Capif ... ${key} - ... server=${CAPIF_HTTPS_URL} + ... server=${server} ... verify=ca.crt - ... username=${value} + ... username=${certificate_name} Status Should Be 204 ${resp} @@ -676,10 +722,56 @@ Remove Resource Should Be Equal As Strings ${resp.status_code} 204 +Create Capif Interconnection + [Arguments] + ... ${server} + ... ${ccf_hostname} + ... ${superadmin_username}=${SUPERADMIN_USERNAME} + + ${body}= Create Interconnection Request Body ${ccf_hostname} + + # Create interconnection + ${resp}= Post Request Capif + ... /helper/interconnection/request + ... server=${server} + ... verify=ca.crt + ... username=${superadmin_username} + ... json=${body} + + Should Be Equal As Integers ${resp.status_code} 201 + + Call Method ${CAPIF_USERS} update_ccf_interconnected ${server} ${resp.json()['ccfId']} ${superadmin_username} + + RETURN ${resp} + +Remove Capif Interconnection + [Arguments] + ... ${server} + ... ${ccf_id} + ... ${superadmin_username}=${SUPERADMIN_USERNAME} + # Delete interconnection + ${resp}= Delete Request Capif + ... /helper/interconnection/request/${ccf_id} + ... server=${server} + ... verify=ca.crt + ... username=${superadmin_username} + + Should Be Equal As Integers ${resp.status_code} 204 + + Call Method ${CAPIF_USERS} remove_ccf_interconnected_entry_by_id ${server} ${ccf_id} + + RETURN ${resp} + Invoker Default Onboarding - [Arguments] ${invoker_username}=${INVOKER_USERNAME} + [Arguments] + ... ${invoker_username}=${INVOKER_USERNAME} + ... ${register_server}=${CAPIF_HTTPS_REGISTER_URL} + ... ${capif_server}=${CAPIF_HTTPS_URL} + ${register_user_info}= Register User At Jwt Auth - ... username=${invoker_username} role=${INVOKER_ROLE} + ... username=${invoker_username} + ... role=${INVOKER_ROLE} + ... server=${register_server} # Send Onboarding Request ${request_body}= Create Onboarding Notification Body @@ -689,22 +781,21 @@ Invoker Default Onboarding ${resp}= Post Request Capif ... ${register_user_info['ccf_onboarding_url']} ... json=${request_body} - ... server=${CAPIF_HTTPS_URL} + ... server=${capif_server} ... verify=ca.crt ... access_token=${register_user_info['access_token']} - Set To Dictionary ${register_user_info} api_invoker_id=${resp.json()['apiInvokerId']} - Log Dictionary ${register_user_info} - # Assertions Status Should Be 201 ${resp} Check Variable ${resp.json()} APIInvokerEnrolmentDetails - ${resource_url}= Check Location Header ${resp} ${LOCATION_INVOKER_RESOURCE_REGEX} + Set To Dictionary ${register_user_info} api_invoker_id=${resp.json()['apiInvokerId']} + Log Dictionary ${register_user_info} + ${resource_url}= Check Location Header ${resp} ${LOCATION_INVOKER_RESOURCE_REGEX} hostname=${capif_server} # Store dummy signede certificate Store In File ${invoker_username}.crt ${resp.json()['onboardingInformation']['apiInvokerCertificate']} ${url}= Parse Url ${resp.headers['Location']} - Call Method ${CAPIF_USERS} update_capif_users_dicts ${url.path} ${invoker_username} + Call Method ${CAPIF_USERS} update_capif_users_dicts ${url.path} ${invoker_username} ${capif_server} Set To Dictionary ${register_user_info} resource_url=${resource_url} Set To Dictionary ${register_user_info} management_cert=${invoker_username} @@ -712,7 +803,9 @@ Invoker Default Onboarding RETURN ${register_user_info} ${url} ${request_body} Provider Registration - [Arguments] ${register_user_info} + [Arguments] + ... ${register_user_info} + ... ${server}=${CAPIF_HTTPS_URL} ${api_prov_funcs}= Create List @@ -733,13 +826,13 @@ Provider Registration ${resp}= Post Request Capif ... /api-provider-management/v1/registrations ... json=${request_body} - ... server=${CAPIF_HTTPS_URL} + ... server=${server} ... verify=ca.crt ... access_token=${register_user_info['access_token']} # Check Results Check Response Variable Type And Values ${resp} 201 APIProviderEnrolmentDetails - ${resource_url}= Check Location Header ${resp} ${LOCATION_PROVIDER_RESOURCE_REGEX} + ${resource_url}= Check Location Header ${resp} ${LOCATION_PROVIDER_RESOURCE_REGEX} hostname=${server} Log Dictionary ${resp.json()} @@ -786,6 +879,7 @@ Provider Registration ... update_capif_users_dicts ... ${register_user_info['resource_url'].path} ... ${register_user_info['amf_username']} + ... ${server} RETURN ${register_user_info} @@ -797,6 +891,8 @@ Provider Default Registration ... ${total_amf_roles}=1 ... ${apf_id}=${NONE} ... ${apf_username}=${NONE} + ... ${register_server}=${CAPIF_HTTPS_REGISTER_URL} + ... ${capif_server}=${CAPIF_HTTPS_URL} # Register Provider ${register_user_info}= Register User At Jwt Auth Provider @@ -804,8 +900,9 @@ Provider Default Registration ... total_apf_roles=${total_apf_roles} ... total_aef_roles=${total_aef_roles} ... total_amf_roles=${total_amf_roles} + ... server=${register_server} - ${register_user_info}= Provider Registration ${register_user_info} + ${register_user_info}= Provider Registration ${register_user_info} ${capif_server} Log Dictionary ${register_user_info} @@ -825,6 +922,12 @@ Publish Service Api Request ... ${security_methods}=default ... ${domain_name}=${NONE} ... ${interface_descriptions}=${NONE} + ... ${is_shareable}=${NONE} + ... ${capif_prov_doms}=${NONE} + ... ${service_api_category}=${NONE} + ... ${pub_api_path_ccf_ids}=${NONE} + ... ${ccf_id}=${NONE} + ... ${server}=${NONE} ${aef_ids}= Create List IF "${aef_id}" == "${NONE}" @@ -849,20 +952,25 @@ Publish Service Api Request END ${request_body}= Create Service Api Description - ... ${service_name} - ... ${aef_ids} - ... ${supported_features} - ... ${vendor_specific_service_api_description} - ... ${vendor_specific_aef_profile} - ... ${api_status} - ... ${security_methods} - ... ${domain_name} - ... ${interface_descriptions} + ... api_name=${service_name} + ... aef_id=${aef_ids} + ... supported_features=${supported_features} + ... vendor_specific_service_api_description=${vendor_specific_service_api_description} + ... vendor_specific_aef_profile=${vendor_specific_aef_profile} + ... api_status=${api_status} + ... security_methods=${security_methods} + ... domain_name=${domain_name} + ... interface_descriptions=${interface_descriptions} + ... is_shareable=${is_shareable} + ... capif_prov_doms=${capif_prov_doms} + ... service_api_category=${service_api_category} + ... pub_api_path_ccf_ids=${pub_api_path_ccf_ids} + ... ccf_id=${ccf_id} ${resp}= Post Request Capif ... /published-apis/v1/${apf_id_to_use}/service-apis ... json=${request_body} - ... server=${CAPIF_HTTPS_URL} + ... server=${server} ... verify=ca.crt ... username=${apf_username_to_use} @@ -882,6 +990,12 @@ Publish Service Api ... ${security_methods}=default ... ${domain_name}=${NONE} ... ${interface_descriptions}=${NONE} + ... ${is_shareable}=${NONE} + ... ${capif_prov_doms}=${NONE} + ... ${service_api_category}=${NONE} + ... ${pub_api_path_ccf_ids}=${NONE} + ... ${ccf_id}=${NONE} + ... ${server}=${CAPIF_HTTPS_URL} ${resp} ${request_body}= Publish Service Api Request ... ${register_user_info_provider} @@ -896,15 +1010,23 @@ Publish Service Api ... ${security_methods} ... ${domain_name} ... ${interface_descriptions} + ... ${is_shareable} + ... ${capif_prov_doms} + ... ${service_api_category} + ... ${pub_api_path_ccf_ids} + ... ${ccf_id} + ... server=${server} Check Response Variable Type And Values ${resp} 201 ServiceAPIDescription Dictionary Should Contain Key ${resp.json()} apiId - ${resource_url}= Check Location Header ${resp} ${LOCATION_PUBLISH_RESOURCE_REGEX} + ${resource_url}= Check Location Header ${resp} ${LOCATION_PUBLISH_RESOURCE_REGEX} hostname=${server} RETURN ${resp.json()} ${resource_url} ${request_body} Basic ACL registration - [Arguments] ${create_security_context}=${True} + [Arguments] + ... ${create_security_context}=${True} + ... ${server}=${CAPIF_HTTPS_URL} # Register APF ${register_user_info_provider}= Provider Default Registration @@ -918,7 +1040,7 @@ Basic ACL registration # Retrieve Services 1 ${resp}= Get Request Capif ... /published-apis/v1/${register_user_info_provider['apf_id']}/service-apis/${serviceApiId} - ... server=${CAPIF_HTTPS_URL} + ... server=${server} ... verify=ca.crt ... username=${APF_PROVIDER_USERNAME} @@ -928,12 +1050,12 @@ Basic ACL registration # Default Invoker Registration and Onboarding ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding - Call Method ${CAPIF_USERS} update_capif_users_dicts ${url.path} ${INVOKER_USERNAME} + Call Method ${CAPIF_USERS} update_capif_users_dicts ${url.path} ${INVOKER_USERNAME} ${server} # Test ${discover_response}= Get Request Capif ... ${DISCOVER_URL}${register_user_info_invoker['api_invoker_id']}&aef-id=${register_user_info_provider['aef_id']} - ... server=${CAPIF_HTTPS_URL} + ... server=${server} ... verify=ca.crt ... username=${INVOKER_USERNAME} @@ -947,12 +1069,12 @@ Basic ACL registration ${resp}= Put Request Capif ... /capif-security/v1/trustedInvokers/${register_user_info_invoker['api_invoker_id']} ... json=${request_body} - ... server=${CAPIF_HTTPS_URL} + ... server=${server} ... verify=ca.crt ... username=${INVOKER_USERNAME} # Check Service Security Check Response Variable Type And Values ${resp} 201 ServiceSecurity - ${resource_url}= Check Location Header ${resp} ${LOCATION_SECURITY_RESOURCE_REGEX} + ${resource_url}= Check Location Header ${resp} ${LOCATION_SECURITY_RESOURCE_REGEX} hostname=${server} END RETURN ${register_user_info_invoker} ${register_user_info_provider} ${service_api_description_published} diff --git a/tests/tasks/Users Management/users.robot b/tests/tasks/Users Management/users.robot index a504f9de3b0c62da92c62231cd088db2a77e4430..def3a6fe82c67594928de59dc11285d4e2fedc68 100644 --- a/tests/tasks/Users Management/users.robot +++ b/tests/tasks/Users Management/users.robot @@ -95,7 +95,7 @@ Remove Client Users Remove Client Users By Prefix [Tags] remove-users-by-prefix - ${users}= Get List of Users At Register + ${users}= Get List of Users At Register ${CAPIF_HTTPS_REGISTER_URL} ${users_to_remove}= Filter Users By Prefix Username users=${users} prefix=${USERNAME_PREFIX}