feat: Introduce header to override authorizer response #1328
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR allows developers to mock AWS_IAM authorizer (and other authorizers) by providing the mock data independently for each REST/HTTP API call by adding the SLS_OFFLINE_AUTHORIZER_OVERRIDE http header.
Motivation and Context
serverless offline does not support AWS_IAM as an authorizer, but this is a common deployment architecture especially when using cognito identity pools.
It was already possible to 'mock' the authorizer by providing a JSON object in process.env.AUTHORIZER, but this does not allow developers to run a test suite with different auth states against a single instance of serverless offline.
This PR allows developers to more fully test their gateway and lambda implementations against a single instance of serverless offline.
How Has This Been Tested?
This PR includes additional integration tests demonstrating the behaviour with and without the inclusion of the SLS_OFFLINE_AUTHORIZER_OVERRIDE header.
Screenshots (if appropriate):