Ocf212 open discover robot tests

Proposers

  • Jorge Moratinos (TID)
  • Pelayo Torres (TID)

Description

Robot tests for the OpenDiscover service have been developed, following the test plan outlined in the documentation.

Demo or definition of done

The six tests verifying the openDiscover service have been developed and can be run to check the service.

Acknowledgements

This work is funded by the European Commission through the HORIZON-JU-SNS-2022 FLEX-SCALE project with Grant Agreement number 101096909.

Edited by Pelayo Torres

Merge request reports

Loading
+23 −4
Changes for services/TS29222_CAPIF_Open_Discover_Service_API/openapi_server/core/open_discover_operations.py: 23 added lines, 4 removed lines.
Original line number Diff line number Diff line
@@ -464,14 +464,33 @@ class OpenDiscoverOperations(Resource):

                if param == "api_supported_features":
                    if isinstance(query_params[param], dict):
                        for api_name, api_supp_feat in query_params[param].items():
                            my_params.append({"$and": [{"api_name": api_name}, {"api_supp_feats": api_supp_feat}]})
                        # Each (api_name, api_supp_feat) pair is an independent
                        # alternative match, not a joint requirement on a single
                        # document - combine with $or, not $and.
                        feature_conditions = [
                            {"$and": [{"api_name": api_name}, {"api_supp_feats": api_supp_feat}]}
                            for api_name, api_supp_feat in query_params[param].items()
                        ]
                        if len(feature_conditions) == 1:
                            my_params.append(feature_conditions[0])
                        elif feature_conditions:
                            my_params.append({"$or": feature_conditions})
                    else:
                        my_params.append({query_params_name[param]: query_params[param]})
                    continue

                for entry in self._ensure_list(query_params[param]):
                    my_params.append({query_params_name[param]: entry})
                # api_names, api_ids, api_cats, api_prov_names: scalar fields.
                # A single document cannot equal more than one value at once,
                # so multiple requested values must be combined with $in
                # (any of these), not one $and clause per value (impossible
                # to satisfy, always zero results).
                values = self._split_form_values(query_params[param])
                if not values:
                    continue
                if len(values) == 1:
                    my_params.append({query_params_name[param]: values[0]})
                else:
                    my_params.append({query_params_name[param]: {"$in": values}})

            if my_params:
                my_query = {"$and": my_params}
+1 −1
Changes for services/nginx/maps/95-auth-error.conf: 1 added line, 1 removed line.
Original line number Diff line number Diff line
map "$service:$endpoint:$method:$has_token:$has_cert:$role" $auth_error {
    default '{"status":401,"title":"Unauthorized","detail":"Operation not allowed","cause":"Access denied by policy"}';
    ~^open-discover-service:.*:.*:0:0:.*$  '{"status":401, "title":"Unauthorized" ,"detail":"Access token not present", "cause":"Bearer token is required for this API route"}';
    default '{"status":401,"title":"Unauthorized","detail":"Operation not allowed","cause":"Access denied by policy"}';
    ~^.*:.*:.*:0:0:.*$  '{"status":401, "title":"Unauthorized" ,"detail":"Certifcate not present", "cause":"Certificate is required for this API route"}';
    ~^helper:.*:.*:0:1:(invoker|apf|aef)$  '{"status":401, "title":"Unauthorized" ,"detail":"Role not authorized for this API route", "cause":"User role must be superadmin"}';
    ~^invoker-management:.*:.*:0:1:(amf|apf|aef|ccf)$  '{"status":401, "title":"Unauthorized" ,"detail":"Role not authorized for this API route", "cause":"User role must be invoker"}';
+1 −1
Changes for services/nginx/policies/open-discover-token.conf: 1 added line, 1 removed line.
Original line number Diff line number Diff line
map "$endpoint:$method" $open_discover_token_policy {
    default DENY;
    open_discover_exact:GET ALLOW;
    ~^open_discover_exact:GET ALLOW;
}
+1
Changes for services/register/register_service/core/register_operations.py: 1 added line, 0 removed lines.
Original line number Diff line number Diff line
@@ -69,6 +69,7 @@ class RegisterOperations:
                            ccf_publish_url="published-apis/v1/<apfId>/service-apis",
                            ccf_onboarding_url="api-invoker-management/v1/onboardedInvokers",
                            ccf_discover_url="service-apis/v1/allServiceAPIs?api-invoker-id=",
                            ccf_open_discover_url="open-api-disc/v1/service-apis",
                            ccf_security_url="capif-security/v1/trustedInvokers/<apiInvokerId>"), 200

        except Exception as e:
+2
Changes for tests/features/CAPIF Api Open Discover Service/__init__.robot: 2 added lines, 0 removed lines.
Original line number Diff line number Diff line
*** Settings ***
Force Tags    capif_api_open_discover_service
 No newline at end of file
Loading
Loading