[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 <cole.walker@windriver.com>
Change-Id: I3c67af481d86966fcb78270c34ad9f6e6468c63c
This commit is contained in:
Cole Walker 2022-11-30 15:51:46 -05:00
parent 3123d63cfb
commit 6a2e65d412
2 changed files with 5 additions and 2 deletions

View File

@ -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]

View File

@ -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: