From c9a9e90a7e09f7063e86462bce5f0ac5007e30a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roberto=20Abdelkader=20Mart=C3=ADnez=20P=C3=A9rez?= Date: Fri, 30 Aug 2019 12:33:29 +0200 Subject: [PATCH] Fix Invalid Path Resource error --- poc/bin/kapow | 5 ++++- .../test/features/data/handler/error_invalidresource.feature | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/poc/bin/kapow b/poc/bin/kapow index fe43bb0..3243ba1 100755 --- a/poc/bin/kapow +++ b/poc/bin/kapow @@ -181,7 +181,10 @@ async def get_field(request): except KeyError: response = web.HTTPNotFound() else: - content = await connection.get(field) + try: + content = await connection.get(field) + except ValueError: + return web.Response(status=400, reason="Invalid Resource Path") if isinstance(content, StreamReader): response = web.StreamResponse(status=200, reason="OK") diff --git a/spec/test/features/data/handler/error_invalidresource.feature b/spec/test/features/data/handler/error_invalidresource.feature index eeeab48..55e6792 100644 --- a/spec/test/features/data/handler/error_invalidresource.feature +++ b/spec/test/features/data/handler/error_invalidresource.feature @@ -10,6 +10,6 @@ Feature: Fail to retrieve an invalid resource for a handler in Kapow! server. | method | url_pattern | | GET | /listRootDir | When I send a request to the testing route "/listRootDir" - And I get the resource "invented/path" + And I get the resource "/invented/path" Then I get 400 as response code And I get "Invalid Resource Path" as response reason phrase