Commit 0725b52b authored by Stavros-Anastasios Charismiadis's avatar Stavros-Anastasios Charismiadis
Browse files

Not working commits

parent eaf9090f
Loading
Loading
Loading
Loading
Loading
+0 −21
Original line number Original line Diff line number Diff line
@@ -63,32 +63,11 @@ class APIProviderEnrolmentDetails(Model):
        self._fail_reason = fail_reason
        self._fail_reason = fail_reason
        self._api_prov_name = api_prov_name
        self._api_prov_name = api_prov_name


    # @classmethod
    # def supp_feat_negotiation(cls, supp_feat):
    #     # convert hex string to int
    #     supp_feat_in_hex = int(supp_feat, 16)
    #     # CAPIF supported features
    #     capif_supp_feat = int("f" * len(supp_feat), 16)
    #
    #     # bitwise AND to determine the supported features
    #     supp_feat_in_hex = supp_feat_in_hex & capif_supp_feat
    #     # Convert the determined supported features field to string (with the same length as the initial)
    #     supp_feat_in_bin = bin(supp_feat_in_hex)[2:].zfill(len(supp_feat)*4)
    #
    #     # current_app.logger.info(supp_feat_in_hex)
    #     # current_app.logger.info(supp_feat_in_bin)
    #     return supp_feat_in_bin

    @classmethod
    @classmethod
    def return_supp_feat_dict(cls, supp_feat):
    def return_supp_feat_dict(cls, supp_feat):


        TOTAL_FEATURES = 2
        TOTAL_FEATURES = 2
        supp_feat_in_hex = int(supp_feat, 16)
        supp_feat_in_hex = int(supp_feat, 16)
        #     # CAPIF supported features
        #     capif_supp_feat = int("f" * len(supp_feat), 16)
        #     or capif_supp_feat = int("1", 16) for only RNAA
        #     # bitwise AND to determine the supported features
        #     supp_feat_in_hex = supp_feat_in_hex & capif_supp_feat
        supp_feat_in_bin = bin(supp_feat_in_hex)[2:].zfill(TOTAL_FEATURES)[::-1]
        supp_feat_in_bin = bin(supp_feat_in_hex)[2:].zfill(TOTAL_FEATURES)[::-1]


        return {
        return {
+16 −2
Original line number Original line Diff line number Diff line
@@ -13,6 +13,7 @@ from service_apis.models.service_kpis import ServiceKpis # noqa: E501
from service_apis import util
from service_apis import util


from ..core.discoveredapis import DiscoverApisOperations
from ..core.discoveredapis import DiscoverApisOperations
from ..core.responses import bad_request_error
from flask import Response, request, current_app
from flask import Response, request, current_app
import json
import json


@@ -60,16 +61,29 @@ def all_service_apis_get(api_invoker_id, api_name=None, api_version=None, comm_t


    query_params = {"api_name": api_name, "api_version": api_version, "comm_type": comm_type,
    query_params = {"api_name": api_name, "api_version": api_version, "comm_type": comm_type,
                    "protocol": protocol, "aef_id": aef_id, "data_format": data_format,
                    "protocol": protocol, "aef_id": aef_id, "data_format": data_format,
                    "api_cat": api_cat, "api_supported_features": api_supported_features,
                    "api_cat": api_cat, "api_prov_name": req_api_prov_name, "api_supported_features": api_supported_features,
                    "supported_features": supported_features}
                    "supported_features": supported_features, "ue_ip_addr": ue_ip_addr }


    if supported_features is not None:
    if supported_features is not None:
        supp_feat_dict = DiscoveredAPIs.return_supp_feat_dict(supported_features)
        supp_feat_dict = DiscoveredAPIs.return_supp_feat_dict(supported_features)
        current_app.logger.info(supp_feat_dict)
        current_app.logger.info(supp_feat_dict)
        vs_fields_exist = False
        if supp_feat_dict['VendSpecQueryParams']:
        if supp_feat_dict['VendSpecQueryParams']:
            for q_params in request.args:
            for q_params in request.args:
                if "vend-spec" in q_params:
                if "vend-spec" in q_params:
                    query_params[q_params] = json.loads(request.args[q_params])
                    query_params[q_params] = json.loads(request.args[q_params])
                    vs_fields_exist = True
            if not vs_fields_exist:
                return bad_request_error(
                    detail="If VendorExt feature is enabled, then vendor-specific parameters are mandatory",
                    cause="Mandatory parameters missing",
                    invalid_params=[{"param": "vendor extensibility parameters", "reason": "missing"}]
                )
        if supp_feat_dict['RNAA']:
            if not query_params["api_prov_name"] and not query_params["ue_ip_addr"]:
                return bad_request_error(detail="req_api_prov_name or ue_ip_addr parameters are mandatory when RNAA is enabled",
                                         cause="Mandatory parameters missing", invalid_params=[
                        {"param": "req-api-prov-name or ue-ip-addr", "reason": "missing"}])


    response = discover_apis.get_discoveredapis(api_invoker_id, query_params)
    response = discover_apis.get_discoveredapis(api_invoker_id, query_params)
    return response
    return response
+1 −0
Original line number Original line Diff line number Diff line
@@ -47,6 +47,7 @@ class DiscoverApisOperations(Resource):
                "aef_id": '{"aef_profiles": {"$elemMatch": {"aef_id":"QPV"}}}',
                "aef_id": '{"aef_profiles": {"$elemMatch": {"aef_id":"QPV"}}}',
                "data_format": '{"aef_profiles": {"$elemMatch": {"data_format":"QPV"}}}',
                "data_format": '{"aef_profiles": {"$elemMatch": {"data_format":"QPV"}}}',
                "api_cat": "service_api_category",
                "api_cat": "service_api_category",
                "api_prov_name": "api_prov_name",
                "supported_features": "supported_features",
                "supported_features": "supported_features",
                "api_supported_features": "api_supp_feats"
                "api_supported_features": "api_supp_feats"
            }
            }
+1 −1
Original line number Original line Diff line number Diff line
@@ -1168,6 +1168,7 @@ components:
      type: object
      type: object
    IpAddrInfo:
    IpAddrInfo:
      description: Represents the UE IP address information.
      description: Represents the UE IP address information.
      type: string
      nullable: true
      nullable: true
      oneOf: []
      oneOf: []
      properties:
      properties:
@@ -1181,7 +1182,6 @@ components:
            string identifying a Ipv6 address formatted according to clause 4 in IETF RFC 5952. The mixed Ipv4 Ipv6 notation according to clause 5 of IETF RFC 5952 shall not be used.
            string identifying a Ipv6 address formatted according to clause 4 in IETF RFC 5952. The mixed Ipv4 Ipv6 notation according to clause 5 of IETF RFC 5952 shall not be used.
          title: Ipv6Addr
          title: Ipv6Addr
          type: string
          type: string
      type: object
    CommunicationType:
    CommunicationType:
      type: string
      type: string
      anyOf:
      anyOf:
+9 −0
Original line number Original line Diff line number Diff line
@@ -8,6 +8,7 @@ from cryptography.hazmat.backends import default_backend
from ..core.validate_user import ControlAccess
from ..core.validate_user import ControlAccess
from functools import wraps
from functools import wraps
from published_apis.vendor_specific import vendor_specific_key_n_value, find_attribute_in_body
from published_apis.vendor_specific import vendor_specific_key_n_value, find_attribute_in_body
from published_apis.rnaa import find_rnaa_attribute_in_body
from ..core.responses import bad_request_error
from ..core.responses import bad_request_error




@@ -105,6 +106,14 @@ def apf_id_service_apis_post(apf_id, body): # noqa: E501
            invalid_params=[{"param": "vendor extensibility", "reason": "wrong definition"}]
            invalid_params=[{"param": "vendor extensibility", "reason": "wrong definition"}]
        )
        )


    current_app.logger.info(body)
    rnaa_fields = find_rnaa_attribute_in_body(body, '')
    current_app.logger.info(rnaa_fields)
    if supp_feat_dict['RNAA'] ^ bool(rnaa_fields):
        return bad_request_error(detail="If and only if RNAA  feature is enabled, req_api_prov_name or ue_ip_addr parameters are mandatory",
                                 cause="Mandatory parameters missing", invalid_params=[
                {"param": "apiProvName or ueIpRange", "reason": "missing"}])

    if request.is_json:
    if request.is_json:
        if supp_feat_dict['VendorExt']:
        if supp_feat_dict['VendorExt']:
            vendor_specific = vendor_specific_key_n_value(vendor_specific_fields, body)
            vendor_specific = vendor_specific_key_n_value(vendor_specific_fields, body)
Loading