Documentation
¶
Overview ¶
Package lambdatest is a container-free end-to-end harness for the Lambda functions: an httptest server that speaks the Lambda Invoke API and routes FunctionName plus Qualifier to in-process lambdaapp.Function handlers.
The qualifier is what a deployment makes it: the alias `live-<class>` is the caller's identity (internal/modcall/lambdacall), so the emulator hands the handler an invoked-function ARN ending in the qualifier and the function derives the caller class from it exactly as it does on the platform. Nothing else about the caller reaches the function.
For tests only. State is the in-memory port, secrets are a small SSM fake (SSM), and GitHub is internal/githubapp/githubfake; no container runs.
Index ¶
Constants ¶
const ( Region = "test-region-1" Account = "111122223333" )
Region and Account are what the emulator's ARNs carry.
const Instance = "acme"
Instance is the instance name the fixture's SSM root and functions carry.
const RecoveryPasswordParam = "/sluis/" + Instance + "/internal/oidc/recovery-password"
RecoveryPasswordParam is where layout v5 keeps the recovery password.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Call ¶
type Call struct {
Function string
Qualifier string
// Class is the caller class the qualifier names (`live-issuer` is "issuer");
// empty for `live` and for a qualifier that is no class.
Class string
Payload []byte
}
Call is one invocation the emulator served.
type Emulator ¶
type Emulator struct {
// contains filtered or unexported fields
}
Emulator is the Lambda Invoke API over httptest.
func (*Emulator) Client ¶
Client is a Lambda client for the emulator: what the production transport (lambdacall.Caller, the run-now trigger) is given as its API.
func (*Emulator) Invoke ¶
func (e *Emulator) Invoke(ctx context.Context, function, qualifier string, event []byte) (Result, error)
Invoke invokes function through qualifier with the event, over the wire.
type Harness ¶
type Harness struct {
Emulator *Emulator
SSM *SSM
// GitHub is the organisation githubfake serves. It points the GitHub client
// at itself for the test's duration, so a test using the harness must not
// run in parallel with another that does.
GitHub *githubfake.Org
}
Harness is one installation, in process: the emulator, the SSM its functions read secrets from, and the GitHub organisation they talk to. State and blobs are the in-memory port.
func NewHarness ¶
NewHarness starts the emulator, the SSM fake (holding the fixture's declared secret) and the GitHub fake. It sets the environment the AWS SDK reads so that nothing reaches a real endpoint.
func (*Harness) IssuerDocument ¶
IssuerDocument writes the issuer's service document: layout v5 secrets in the harness's SSM, state and blobs in memory, and the run-now trigger in memory (the v1.76 scenarios replace it with the invoke trigger aimed at the emulator). It returns the file's path.
type Result ¶
Result is what an invocation answered: the payload, and FunctionError when the function failed (the platform answers 200 with the error set).
type SSM ¶
type SSM struct {
// contains filtered or unexported fields
}
SSM is SSM Parameter Store over its wire protocol (JSON 1.1, the operation in X-Amz-Target), enough for the secrets reads a function makes: the real client, with its retryer, talks to it. Parameters are by full name.
func (*SSM) Reads ¶
Reads are the parameters and paths asked for so far, in order, by whatever reached this fake: a test that gives each function its own fake can say what that function never read.