Merge pull request #2707 from UltCombo/patch-1
Support greedy resource path in API Gateway
This commit is contained in:
commit
b6aeae0f2d
@ -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.",
|
||||
)
|
||||
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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:
|
||||
|
Loading…
Reference in New Issue
Block a user