Skip to content
This repository has been archived by the owner on Feb 11, 2023. It is now read-only.

Debug & Test

Payton Garland edited this page Mar 16, 2018 · 5 revisions

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.

How it works

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.

Test Configuration

In a file called test-config.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.
  • lambdaFunction
    • Name of Lambda Function
  • aws
    • accessKeyId
    • secretAccessKey
    • region

Example

{
    "port": 8080,
    "auth": "y/n",
    "lambdaFunction": "LF",
    "aws": {
        "accessKeyId": "AKID", 
        "secretAccessKey": "SAK", 
        "region": "R"
    }
}
Clone this wiki locally