Implement support for lambda policies (#2471)

* Implement support for lambda policies

* Fixing two tests that weren't running

* Getting tests running under Python 2.7
This commit is contained in:
Jack Danger 2019-10-22 14:09:44 -07:00 committed by GitHub
commit a05c7da3bb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 12 deletions

View file

@ -117,6 +117,7 @@ class LambdaResponse(BaseResponse):
raise ValueError("Cannot handle {0} request".format(request.method))
def policy(self, request, full_url, headers):
self.setup_class(request, full_url, headers)
if request.method == 'GET':
return self._get_policy(request, full_url, headers)
if request.method == 'POST':
@ -140,7 +141,7 @@ class LambdaResponse(BaseResponse):
path = request.path if hasattr(request, 'path') else path_url(request.url)
function_name = path.split('/')[-2]
if self.lambda_backend.get_function(function_name):
policy = request.body.decode('utf8')
policy = self.body
self.lambda_backend.add_policy(function_name, policy)
return 200, {}, json.dumps(dict(Statement=policy))
else: