def test_auth_response_serialization(): method_arn = ( "arn:aws:execute-api:us-west-2:123:rest-api-id/dev/GET/needs/auth") request = app.AuthRequest('TOKEN', 'authtoken', method_arn) response = app.AuthResponse(routes=['/needs/auth'], principal_id='foo') response_dict = response.to_dict(request) expected = [method_arn.replace('GET', '*')] assert response_dict == { 'policyDocument': { 'Version': '2012-10-17', 'Statement': [{ 'Action': 'execute-api:Invoke', 'Resource': expected, 'Effect': 'Allow' }] }, 'context': {}, 'principalId': 'foo', }
def auth_request(): method_arn = ( "arn:aws:execute-api:us-west-2:123:rest-api-id/dev/GET/needs/auth") request = app.AuthRequest('TOKEN', 'authtoken', method_arn) return request