From 55a1c2fb590b333e43353a7bd01790990da07a5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabr=C3=ADcio=20Matt=C3=A9?= Date: Tue, 28 Jan 2020 20:45:19 -0300 Subject: [PATCH 1/3] Support greedy resource path --- moto/apigateway/models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/moto/apigateway/models.py b/moto/apigateway/models.py index fd2fb7064..748a09e0f 100644 --- a/moto/apigateway/models.py +++ b/moto/apigateway/models.py @@ -556,7 +556,7 @@ class APIGatewayBackend(BaseBackend): return resource def create_resource(self, function_id, parent_resource_id, path_part): - if not re.match("^\\{?[a-zA-Z0-9._-]+\\}?$", path_part): + if not re.match("^\\{?[a-zA-Z0-9._-]+\\+?\\}?$", path_part): raise InvalidResourcePathException() api = self.get_rest_api(function_id) child = api.add_child(path=path_part, parent_id=parent_resource_id) From be8eab18e91f3b10e6b741c195e2b66cc4407ccf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabr=C3=ADcio=20Matt=C3=A9?= Date: Tue, 28 Jan 2020 20:56:13 -0300 Subject: [PATCH 2/3] Update InvalidResourcePathException message --- moto/apigateway/exceptions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/moto/apigateway/exceptions.py b/moto/apigateway/exceptions.py index 434ebc467..2a306ab99 100644 --- a/moto/apigateway/exceptions.py +++ b/moto/apigateway/exceptions.py @@ -39,7 +39,7 @@ class InvalidResourcePathException(BadRequestException): def __init__(self): super(InvalidResourcePathException, self).__init__( "BadRequestException", - "Resource's path part only allow a-zA-Z0-9._- and curly braces at the beginning and the end.", + "Resource's path part only allow a-zA-Z0-9._- and curly braces at the beginning and the end and an optional plus sign before the closing brace.", ) From cf65cfc6ec3a5ae50498ea9938ba8dbe826bb8f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabr=C3=ADcio=20Matt=C3=A9?= Date: Wed, 29 Jan 2020 16:28:37 -0300 Subject: [PATCH 3/3] Update API Gateway resource name test --- tests/test_apigateway/test_apigateway.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/test_apigateway/test_apigateway.py b/tests/test_apigateway/test_apigateway.py index 59c0c07f6..601aa2952 100644 --- a/tests/test_apigateway/test_apigateway.py +++ b/tests/test_apigateway/test_apigateway.py @@ -58,15 +58,15 @@ def test_create_resource__validate_name(): 0 ]["id"] - invalid_names = ["/users", "users/", "users/{user_id}", "us{er"] - valid_names = ["users", "{user_id}", "user_09", "good-dog"] + invalid_names = ["/users", "users/", "users/{user_id}", "us{er", "us+er"] + valid_names = ["users", "{user_id}", "{proxy+}", "user_09", "good-dog"] # All invalid names should throw an exception for name in invalid_names: with assert_raises(ClientError) as ex: client.create_resource(restApiId=api_id, parentId=root_id, pathPart=name) ex.exception.response["Error"]["Code"].should.equal("BadRequestException") ex.exception.response["Error"]["Message"].should.equal( - "Resource's path part only allow a-zA-Z0-9._- and curly braces at the beginning and the end." + "Resource's path part only allow a-zA-Z0-9._- and curly braces at the beginning and the end and an optional plus sign before the closing brace." ) # All valid names should go through for name in valid_names: