add more realistic policy

This commit is contained in:
Chris Keogh 2017-10-03 13:54:37 +13:00
parent fc9c250922
commit b994cf5291
2 changed files with 9 additions and 2 deletions

View File

@ -67,7 +67,10 @@ class LambdaResponse(BaseResponse):
path = request.path if hasattr(request, 'path') else request.path_url
function_name = path.split('/')[-2]
if lambda_backend.has_function(function_name):
return 200, {}, json.dumps(dict(Policy='test_policy'))
policy = ("{\"Statement\":[{\"Action\":[\"lambda:InvokeFunction\"],"
"\"Resource\":\"arn:aws:lambda:us-west-2:account-id:function:helloworld\","
"\"Effect\":\"Allow\",\"Principal\":{\"AWS\":\"account-id\"},\"Sid\":\"3\"}]}")
return 200, {}, json.dumps(dict(Policy=policy))
else:
return 404, {}, "{}"

View File

@ -667,4 +667,8 @@ def get_function_policy():
response = conn.get_policy(
FunctionName='testFunction'
)
assert response['Policy'] == 'test_policy'
assert 'Policy' in response
assert isinstance(response['Policy'], str)
res = json.loads(response['Policy'])
assert res['Statement'][0]['Action'] == ['lambda:InvokeFunction']