From 1a2198e2447bdb7c2c3c2b50f42253e8d6a1b274 Mon Sep 17 00:00:00 2001 From: Afonso Castanheta Date: Mon, 30 Mar 2026 14:25:40 +0000 Subject: [PATCH] Fix error response messages and validation logic in Events Service --- .../capif_events/core/events_apis.py | 2 +- .../capif_events/core/validate_user.py | 2 +- tests/features/CAPIF Api Events/capif_events_api.robot | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/services/TS29222_CAPIF_Events_API/capif_events/core/events_apis.py b/services/TS29222_CAPIF_Events_API/capif_events/core/events_apis.py index ae4674e7..cb4b48d4 100644 --- a/services/TS29222_CAPIF_Events_API/capif_events/core/events_apis.py +++ b/services/TS29222_CAPIF_Events_API/capif_events/core/events_apis.py @@ -220,7 +220,7 @@ class EventSubscriptionsOperations(Resource): if eventdescription is None: current_app.logger.error("Event subscription not found") - return not_found_error(detail="Event subscription not exist", cause="Event API subscription id not found") + return not_found_error(detail="Event subscription does not exist", cause="Event API subscription id not found") mycol.delete_one(my_query) notifications_col.delete_many({"subscription_id": subscription_id}) diff --git a/services/TS29222_CAPIF_Events_API/capif_events/core/validate_user.py b/services/TS29222_CAPIF_Events_API/capif_events/core/validate_user.py index 8d1f8b05..3370c1d6 100644 --- a/services/TS29222_CAPIF_Events_API/capif_events/core/validate_user.py +++ b/services/TS29222_CAPIF_Events_API/capif_events/core/validate_user.py @@ -25,7 +25,7 @@ class ControlAccess(Resource): prob = serialize_clean_camel_case(prob) return Response(json.dumps(prob, cls=CustomJSONEncoder), status=401, mimetype="application/json") - elif event_id is not None and (cert_entry["cert_signature"] != cert_signature or "event_subscriptions" not in cert_entry["resources"] or event_id not in cert_entry["resources"]["event_subscriptions"]): + elif event_id is not None and (cert_entry["cert_signature"] != cert_signature or "event_subscriptions" not in cert_entry["resources"]): prob = ProblemDetails(title="Unauthorized", detail="User not authorized", cause="You are not the owner of this resource") prob = serialize_clean_camel_case(prob) diff --git a/tests/features/CAPIF Api Events/capif_events_api.robot b/tests/features/CAPIF Api Events/capif_events_api.robot index 4da4228d..df0ea678 100644 --- a/tests/features/CAPIF Api Events/capif_events_api.robot +++ b/tests/features/CAPIF Api Events/capif_events_api.robot @@ -135,10 +135,10 @@ Deletes an individual CAPIF Event Subscription with invalid SubscriptionId ... username=${INVOKER_USERNAME} # Check Results - Check Response Variable Type And Values ${resp} 401 ProblemDetails - ... title=Unauthorized - ... detail=User not authorized - ... cause=You are not the owner of this resource + Check Response Variable Type And Values ${resp} 404 ProblemDetails + ... title=Not Found + ... detail=Event subscription does not exist + ... cause=Event API subscription id not found Invoker receives Service API Invocation events [Tags] capif_api_events-6 mockserver smoke -- GitLab