From 6a2e65d412f9189d04a12fd66d82a6268ae8728b Mon Sep 17 00:00:00 2001 From: Cole Walker Date: Wed, 30 Nov 2022 15:51:46 -0500 Subject: [PATCH] [PTP] Fix logic for handling incorrect v2 subscription POST Fixed an issue where attempting to GET a subscription by ID was failing. DELETE by subscription ID was also failing. The logic to return 404 on an incorrect v2 subscription POST was breaking the ability to get subscriptions by ID. Added a dedicated method to handle the incorrect POST and returned the subscription GET logic to the original form. Test plan: PASS: Build and deploy notification-client base PASS: Test v1 and v2 pull status, subscribe, get subscription, delete PASS: Invalid POST to v2 subscription endpoint returns 404 Closes-bug: 1998394 Signed-off-by: Cole Walker Change-Id: I3c67af481d86966fcb78270c34ad9f6e6468c63c --- .../notificationclient-sidecar/sidecar/controllers/root.py | 3 +-- .../sidecar/controllers/v2/subscriptions.py | 4 ++++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/notificationclient-base/docker/notificationclient-sidecar/sidecar/controllers/root.py b/notificationclient-base/docker/notificationclient-sidecar/sidecar/controllers/root.py index 5e552dc..f431ace 100644 --- a/notificationclient-base/docker/notificationclient-sidecar/sidecar/controllers/root.py +++ b/notificationclient-base/docker/notificationclient-sidecar/sidecar/controllers/root.py @@ -57,8 +57,7 @@ class V2Controller(rest.RestController): def _lookup(self, primary_key, *remainder): if primary_key: if 'subscriptions' == primary_key.lower(): - if not remainder: - return SubscriptionsControllerV2(), remainder + return SubscriptionsControllerV2(), remainder elif remainder: if 'currentstate' == remainder[-1].lower(): resource_address_array = remainder[:-1] diff --git a/notificationclient-base/docker/notificationclient-sidecar/sidecar/controllers/v2/subscriptions.py b/notificationclient-base/docker/notificationclient-sidecar/sidecar/controllers/v2/subscriptions.py index 2fd9204..ecf04cf 100644 --- a/notificationclient-base/docker/notificationclient-sidecar/sidecar/controllers/v2/subscriptions.py +++ b/notificationclient-base/docker/notificationclient-sidecar/sidecar/controllers/v2/subscriptions.py @@ -123,6 +123,10 @@ class SubscriptionController(rest.RestController): def __init__(self, subscription_id): self.subscription_id = subscription_id + @expose('json') + def post(self): + abort(404) + @expose('json') def get(self): try: