Commit d1223103 authored by Jorge Moratinos's avatar Jorge Moratinos
Browse files

Improvements over code due to tests results

parent 883b4713
Loading
Loading
Loading
Loading
+19 −15
Original line number Diff line number Diff line
@@ -67,19 +67,6 @@ def shared_capif_prov_doms(shareable_info):

    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):
    final_supp_feat = bin(int(supp_feat, 16) & int(SUPPORTED_FEATURES_HEX, 16))[2:].zfill(TOTAL_FEATURES)[::-1]

@@ -424,7 +411,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 +469,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:
@@ -949,3 +936,20 @@ 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)
+4 −0
Original line number Diff line number Diff line
@@ -134,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),