Loading services/TS29222_CAPIF_Publish_Service_API/published_apis/core/serviceapidescriptions.py +39 −0 Changes for services/TS29222_CAPIF_Publish_Service_API/published_apis/core/serviceapidescriptions.py: 39 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -195,6 +195,7 @@ class PublishServiceOperations(Resource): invalid_params=[{"param": "apiStatus", "reason": "defined but apiStatusMonitoring feature not active"}] ) # Publish APIs to other CCFs interconnected published, interconnection_error = self.publish_to_interconnected_ccfs( rec, self.shared_capif_prov_doms(rec.get("shareable_info"))) Loading Loading @@ -395,6 +396,9 @@ class PublishServiceOperations(Resource): stored before this modification. Returns an error response if a peer could not be reached or refused the update. """ # store local api_id local_api_id = service_api.get("api_id") if not capif_prov_doms: return None Loading Loading @@ -443,6 +447,10 @@ class PublishServiceOperations(Resource): current_app.logger.debug( "Interconnection: service api {} updated on {}".format(shared_api_name, dom)) # Update mapping between local and remote API IDs remote_api_id = response.json().get("api_id") self.update_api_remote_id_map(dom, local_api_id, remote_api_id) # End of update api remote ID map return None def publish_to_interconnected_ccfs(self, service_api, capif_prov_doms): Loading @@ -453,6 +461,9 @@ class PublishServiceOperations(Resource): withdraw the copies already accepted when an error comes back, as they would otherwise be rejected as duplicates by a later attempt. """ # store local api_id local_api_id = service_api.get("api_id") if not capif_prov_doms: return [], None Loading Loading @@ -497,6 +508,11 @@ class PublishServiceOperations(Resource): "Interconnection: service api {} published on {}".format( service_api.get("api_name"), dom)) # Update mapping between local and remote API IDs remote_api_id = response.json().get("api_id") self.update_api_remote_id_map(dom, local_api_id, remote_api_id) # End of update api remote ID map return published, None def withdraw_published_copies(self, api_name, published): Loading Loading @@ -964,3 +980,26 @@ class PublishServiceOperations(Resource): return dst_prov_doms # return shareable_info.get("capif_prov_doms") or [] def update_api_remote_id_map(self, dom, local_api_id, remote_api_id): """Update the mapping between local and remote API IDs for a given CAPIF domain.""" # Update mapping between local and remote API IDs interconnected_col = self.db.get_col_by_name(self.db.interconnected) interconnected_ccf = interconnected_col.find_one({"dst_prov_dom": dom}) if interconnected_ccf is None: return not_found_error( detail="CAPIF domain {} is not interconnected".format(dom), cause="NOT_FOUND") if interconnected_ccf.get("api_remote_id_map") is None: interconnected_ccf["api_remote_id_map"] = dict() api_remote_id_map = interconnected_ccf.get("api_remote_id_map") if api_remote_id_map.get(local_api_id) is None: api_remote_id_map[local_api_id] = list() if remote_api_id not in api_remote_id_map[local_api_id]: api_remote_id_map[local_api_id].append(remote_api_id) interconnected_col.update_one({"dst_prov_dom": dom}, {"$set": {"api_remote_id_map": api_remote_id_map}}) # End of update api remote ID map services/helper/helper_service/db/db.py +2 −5 Changes for services/helper/helper_service/db/db.py: 2 added lines, 5 removed lines. Original line number Diff line number Diff line Loading @@ -42,10 +42,6 @@ class MongoDatabse(): self.initialize_capif_configuration() def get_col_by_name(self, name): return self.db[name].with_options(codec_options=CodecOptions(tz_aware=True)) def __connect(self, max_retries=3, retry_delay=1): retries = 0 Loading @@ -55,7 +51,6 @@ class MongoDatabse(): uri = f"mongodb://{self.config['mongo']['user']}:{self.config['mongo']['password']}@" \ f"{self.config['mongo']['host']}:{self.config['mongo']['port']}" client = MongoClient(uri) mydb = client[self.config['mongo']['db']] mydb.command("ping") Loading Loading @@ -100,6 +95,8 @@ class MongoDatabse(): _singleton = None def get_mongo(): global _singleton if _singleton is None: Loading services/helper/helper_service/services/interconnection/core/capifdomaindetails.py +2 −3 Changes for services/helper/helper_service/services/interconnection/core/capifdomaindetails.py: 2 added lines, 3 removed lines. Original line number Diff line number Diff line Loading @@ -44,7 +44,7 @@ class CapifDomainOperations(Resource): current_app.logger.debug("Interconnection: Get domains") interconnected_col = self.db.get_col_by_name(self.db.interconnected) interconnected_ccfs = interconnected_col.find({}, {"_id": 0}) interconnected_ccfs = interconnected_col.find({}, {"_id": 0, "api_remote_id_map": 0}) ccfinstances = [ serialize_clean_camel_case(CcfInstanceDetails().from_dict(dict_to_camel_case(interconnected_ccf))) Loading @@ -58,7 +58,7 @@ class CapifDomainOperations(Resource): current_app.logger.debug("Interconnection: Get domain") interconnected_col = self.db.get_col_by_name(self.db.interconnected) interconnected_ccf = interconnected_col.find_one({"ccf_id": ccf_id}, {"_id": 0}) interconnected_ccf = interconnected_col.find_one({"ccf_id": ccf_id}, {"_id": 0, "api_remote_id_map": 0}) if interconnected_ccf is None: return not_found_error( detail="CAPIF domain with ccf_id {} not found".format(ccf_id), Loading Loading @@ -182,4 +182,3 @@ class CapifDomainOperations(Resource): ) return not_found_error("CAPIF domain with ccf_id {} not found".format(ccf_id)) services/helper/helper_service/services/interconnection/core/ccfinstancedetails.py +29 −0 Changes for services/helper/helper_service/services/interconnection/core/ccfinstancedetails.py: 29 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -127,6 +127,7 @@ class CcfInstanceOperations(Resource): }) for service_api in shareable_apis: local_api_id = service_api.get("api_id") payload = { key: value for key, value in service_api.items() if key not in ("_id", "apf_id", "onboarding_date") Loading @@ -151,6 +152,11 @@ class CcfInstanceOperations(Resource): peer_dom, service_api.get("api_name"), response.status_code)) continue # Update mapping between local and remote API IDs remote_api_id = response.json().get("api_id") self.update_api_remote_id_map(peer_dom, local_api_id, remote_api_id) # End of update api remote ID map self.add_ccf_to_pub_api_path(services_col, service_api, peer_ccf_id) published += 1 Loading Loading @@ -245,3 +251,26 @@ class CcfInstanceOperations(Resource): res = not_found_error("CCF instance with ccf_id {} not found".format(ccf_id)) return res def update_api_remote_id_map(self, dom, local_api_id, remote_api_id): """Update the mapping between local and remote API IDs for a given CAPIF domain.""" # Update mapping between local and remote API IDs interconnected_col = self.db.get_col_by_name(self.db.interconnected) interconnected_ccf = interconnected_col.find_one({"dst_prov_dom": dom}) if interconnected_ccf is None: return not_found_error( detail="CAPIF domain {} is not interconnected".format(dom), cause="NOT_FOUND") if interconnected_ccf.get("api_remote_id_map") is None: interconnected_ccf["api_remote_id_map"] = dict() api_remote_id_map = interconnected_ccf.get("api_remote_id_map") if api_remote_id_map.get(local_api_id) is None: api_remote_id_map[local_api_id] = list() if remote_api_id not in api_remote_id_map[local_api_id]: api_remote_id_map[local_api_id].append(remote_api_id) interconnected_col.update_one({"dst_prov_dom": dom}, {"$set": {"api_remote_id_map": api_remote_id_map}}) # End of update api remote ID map tests/tasks/__init__.robot +10 −0 Changes for tests/tasks/__init__.robot: 10 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -46,6 +46,8 @@ Prepare environment # Obtain ca root certificate Retrieve Ca Root Retrieve Superadmin Cert Reset Testing Environment Retrieve Ca Root Loading @@ -54,3 +56,11 @@ Retrieve Ca Root Status Should Be 200 ${resp} Log ${resp.json()['data']['data']['ca']} Store In File ca.crt ${resp.json()['data']['data']['ca']} Retrieve Superadmin Cert [Documentation] This keyword retrieve ca.root from CAPIF and store it at ca.crt in order to use at TLS communications ${resp}= Obtain Superadmin Cert From Vault /v1/pki_int/sign/my-ca ${CAPIF_HTTP_VAULT_URL} Status Should Be 200 ${resp} Log Dictionary ${resp.json()} Log ${resp.json()['data']['certificate']} Store In File ${SUPERADMIN_USERNAME}.crt ${resp.json()['data']['certificate']} Loading
services/TS29222_CAPIF_Publish_Service_API/published_apis/core/serviceapidescriptions.py +39 −0 Changes for services/TS29222_CAPIF_Publish_Service_API/published_apis/core/serviceapidescriptions.py: 39 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -195,6 +195,7 @@ class PublishServiceOperations(Resource): invalid_params=[{"param": "apiStatus", "reason": "defined but apiStatusMonitoring feature not active"}] ) # Publish APIs to other CCFs interconnected published, interconnection_error = self.publish_to_interconnected_ccfs( rec, self.shared_capif_prov_doms(rec.get("shareable_info"))) Loading Loading @@ -395,6 +396,9 @@ class PublishServiceOperations(Resource): stored before this modification. Returns an error response if a peer could not be reached or refused the update. """ # store local api_id local_api_id = service_api.get("api_id") if not capif_prov_doms: return None Loading Loading @@ -443,6 +447,10 @@ class PublishServiceOperations(Resource): current_app.logger.debug( "Interconnection: service api {} updated on {}".format(shared_api_name, dom)) # Update mapping between local and remote API IDs remote_api_id = response.json().get("api_id") self.update_api_remote_id_map(dom, local_api_id, remote_api_id) # End of update api remote ID map return None def publish_to_interconnected_ccfs(self, service_api, capif_prov_doms): Loading @@ -453,6 +461,9 @@ class PublishServiceOperations(Resource): withdraw the copies already accepted when an error comes back, as they would otherwise be rejected as duplicates by a later attempt. """ # store local api_id local_api_id = service_api.get("api_id") if not capif_prov_doms: return [], None Loading Loading @@ -497,6 +508,11 @@ class PublishServiceOperations(Resource): "Interconnection: service api {} published on {}".format( service_api.get("api_name"), dom)) # Update mapping between local and remote API IDs remote_api_id = response.json().get("api_id") self.update_api_remote_id_map(dom, local_api_id, remote_api_id) # End of update api remote ID map return published, None def withdraw_published_copies(self, api_name, published): Loading Loading @@ -964,3 +980,26 @@ class PublishServiceOperations(Resource): return dst_prov_doms # return shareable_info.get("capif_prov_doms") or [] def update_api_remote_id_map(self, dom, local_api_id, remote_api_id): """Update the mapping between local and remote API IDs for a given CAPIF domain.""" # Update mapping between local and remote API IDs interconnected_col = self.db.get_col_by_name(self.db.interconnected) interconnected_ccf = interconnected_col.find_one({"dst_prov_dom": dom}) if interconnected_ccf is None: return not_found_error( detail="CAPIF domain {} is not interconnected".format(dom), cause="NOT_FOUND") if interconnected_ccf.get("api_remote_id_map") is None: interconnected_ccf["api_remote_id_map"] = dict() api_remote_id_map = interconnected_ccf.get("api_remote_id_map") if api_remote_id_map.get(local_api_id) is None: api_remote_id_map[local_api_id] = list() if remote_api_id not in api_remote_id_map[local_api_id]: api_remote_id_map[local_api_id].append(remote_api_id) interconnected_col.update_one({"dst_prov_dom": dom}, {"$set": {"api_remote_id_map": api_remote_id_map}}) # End of update api remote ID map
services/helper/helper_service/db/db.py +2 −5 Changes for services/helper/helper_service/db/db.py: 2 added lines, 5 removed lines. Original line number Diff line number Diff line Loading @@ -42,10 +42,6 @@ class MongoDatabse(): self.initialize_capif_configuration() def get_col_by_name(self, name): return self.db[name].with_options(codec_options=CodecOptions(tz_aware=True)) def __connect(self, max_retries=3, retry_delay=1): retries = 0 Loading @@ -55,7 +51,6 @@ class MongoDatabse(): uri = f"mongodb://{self.config['mongo']['user']}:{self.config['mongo']['password']}@" \ f"{self.config['mongo']['host']}:{self.config['mongo']['port']}" client = MongoClient(uri) mydb = client[self.config['mongo']['db']] mydb.command("ping") Loading Loading @@ -100,6 +95,8 @@ class MongoDatabse(): _singleton = None def get_mongo(): global _singleton if _singleton is None: Loading
services/helper/helper_service/services/interconnection/core/capifdomaindetails.py +2 −3 Changes for services/helper/helper_service/services/interconnection/core/capifdomaindetails.py: 2 added lines, 3 removed lines. Original line number Diff line number Diff line Loading @@ -44,7 +44,7 @@ class CapifDomainOperations(Resource): current_app.logger.debug("Interconnection: Get domains") interconnected_col = self.db.get_col_by_name(self.db.interconnected) interconnected_ccfs = interconnected_col.find({}, {"_id": 0}) interconnected_ccfs = interconnected_col.find({}, {"_id": 0, "api_remote_id_map": 0}) ccfinstances = [ serialize_clean_camel_case(CcfInstanceDetails().from_dict(dict_to_camel_case(interconnected_ccf))) Loading @@ -58,7 +58,7 @@ class CapifDomainOperations(Resource): current_app.logger.debug("Interconnection: Get domain") interconnected_col = self.db.get_col_by_name(self.db.interconnected) interconnected_ccf = interconnected_col.find_one({"ccf_id": ccf_id}, {"_id": 0}) interconnected_ccf = interconnected_col.find_one({"ccf_id": ccf_id}, {"_id": 0, "api_remote_id_map": 0}) if interconnected_ccf is None: return not_found_error( detail="CAPIF domain with ccf_id {} not found".format(ccf_id), Loading Loading @@ -182,4 +182,3 @@ class CapifDomainOperations(Resource): ) return not_found_error("CAPIF domain with ccf_id {} not found".format(ccf_id))
services/helper/helper_service/services/interconnection/core/ccfinstancedetails.py +29 −0 Changes for services/helper/helper_service/services/interconnection/core/ccfinstancedetails.py: 29 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -127,6 +127,7 @@ class CcfInstanceOperations(Resource): }) for service_api in shareable_apis: local_api_id = service_api.get("api_id") payload = { key: value for key, value in service_api.items() if key not in ("_id", "apf_id", "onboarding_date") Loading @@ -151,6 +152,11 @@ class CcfInstanceOperations(Resource): peer_dom, service_api.get("api_name"), response.status_code)) continue # Update mapping between local and remote API IDs remote_api_id = response.json().get("api_id") self.update_api_remote_id_map(peer_dom, local_api_id, remote_api_id) # End of update api remote ID map self.add_ccf_to_pub_api_path(services_col, service_api, peer_ccf_id) published += 1 Loading Loading @@ -245,3 +251,26 @@ class CcfInstanceOperations(Resource): res = not_found_error("CCF instance with ccf_id {} not found".format(ccf_id)) return res def update_api_remote_id_map(self, dom, local_api_id, remote_api_id): """Update the mapping between local and remote API IDs for a given CAPIF domain.""" # Update mapping between local and remote API IDs interconnected_col = self.db.get_col_by_name(self.db.interconnected) interconnected_ccf = interconnected_col.find_one({"dst_prov_dom": dom}) if interconnected_ccf is None: return not_found_error( detail="CAPIF domain {} is not interconnected".format(dom), cause="NOT_FOUND") if interconnected_ccf.get("api_remote_id_map") is None: interconnected_ccf["api_remote_id_map"] = dict() api_remote_id_map = interconnected_ccf.get("api_remote_id_map") if api_remote_id_map.get(local_api_id) is None: api_remote_id_map[local_api_id] = list() if remote_api_id not in api_remote_id_map[local_api_id]: api_remote_id_map[local_api_id].append(remote_api_id) interconnected_col.update_one({"dst_prov_dom": dom}, {"$set": {"api_remote_id_map": api_remote_id_map}}) # End of update api remote ID map
tests/tasks/__init__.robot +10 −0 Changes for tests/tasks/__init__.robot: 10 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -46,6 +46,8 @@ Prepare environment # Obtain ca root certificate Retrieve Ca Root Retrieve Superadmin Cert Reset Testing Environment Retrieve Ca Root Loading @@ -54,3 +56,11 @@ Retrieve Ca Root Status Should Be 200 ${resp} Log ${resp.json()['data']['data']['ca']} Store In File ca.crt ${resp.json()['data']['data']['ca']} Retrieve Superadmin Cert [Documentation] This keyword retrieve ca.root from CAPIF and store it at ca.crt in order to use at TLS communications ${resp}= Obtain Superadmin Cert From Vault /v1/pki_int/sign/my-ca ${CAPIF_HTTP_VAULT_URL} Status Should Be 200 ${resp} Log Dictionary ${resp.json()} Log ${resp.json()['data']['certificate']} Store In File ${SUPERADMIN_USERNAME}.crt ${resp.json()['data']['certificate']}