Commit 4184b8f5 authored by Jorge Moratinos's avatar Jorge Moratinos
Browse files

Fix publish logic to allow share to all connected CAPIFs when capifProvDoms is...

Fix publish logic to allow share to all connected CAPIFs when capifProvDoms is not present at Shareable Info
parent 41a7f653
Loading
Loading
Loading
Loading
Loading
+22 −11
Original line number Diff line number Diff line
@@ -58,14 +58,7 @@ 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 return_negotiated_supp_feat_dict(supp_feat):
    final_supp_feat = bin(int(supp_feat, 16) & int(SUPPORTED_FEATURES_HEX, 16))[2:].zfill(TOTAL_FEATURES)[::-1]
@@ -203,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
@@ -526,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:
@@ -598,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
@@ -953,3 +946,21 @@ class PublishServiceOperations(Resource):
            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