-
Notifications
You must be signed in to change notification settings - Fork 149
Debug & Test
cloudfront-auth
provides users with an easy way to debug and test their lambda function before CloudFront deployment. With the debugger, the entirety of the authentication/authorization process is ran in one sweep and all data is outputted to a log. The debugger will simulate CloudFront requests and users are redirected to a local server with ngrok.
Tests are done by manually invoking the Lambda function without going through CloudFront. Upon manual invocation, a simulated CloudFront payload is used exactly as it would be in production. The responses are then stored in a log for further analysis. To avoid using the production endpoint for CloudFront, we setup a local server and use ngrok to get a temporary endpoint. As a result, tests can be executed without risking the security of content distributed by CloudFront.
To begin tests, create a test configuration file placed in your distribution folder (see below). Next, go to the root directory and run npm test -- distribution
where distribution
is the distribution you named in build. Once finished, a log will be outputted in the logs
folder of your distribution.
In a file called config-test.json
within your distribution folder, fill in the information below. Note: aws information can be found here.
-
port
- Port that local server listens to. ngrok exposes this port.
-
auth
- 'y' or 'n'
- 'y' => basic authentication on ngrok tunnel.
- 'n' => tunnel can be freely accessed.
- 'y' or 'n'
-
lambdaFunction
- Name of Lambda Function
-
aws
accessKeyId
secretAccessKey
region
{
"port": 8080,
"auth": "y/n",
"lambdaFunction": "LF",
"aws": {
"accessKeyId": "AKID",
"secretAccessKey": "SAK",
"region": "R"
}
}