Skip to content

Test context

The runner calls your verification function with two arguments, t and actual. t gives access to the test's original data and assertion methods. actual is the separately calculated Result. You may use different argument names, but their positions have these meanings.

All data properties are read-only. Write expectations with the IsEqual method.

Properties

input

The original input supplied by this Test. For example, t.input.request.host keeps the spelling you wrote, whereas actual.request.host contains the canonical host used for matching.

environment

The supplied suite facts: known users, groups and absences. This is not actual.environment, which describes the selected target settings.

configuration

A small view of the loaded configuration, described below. It is not the whole YAML configuration and exposes no configuration secrets.

Test configuration

This is the value of t.configuration.

flows

The configured flows in configuration order. No authorizer or environment configuration objects are exposed through this view.

Test flow

Each entry in t.configuration.flows has one property:

name

The configured flow name. For example, t.configuration.flows[1].name.

Methods

t:IsEqual(expected, actual, reason?) compares values and records the result as an assertion.

Examples

The callback's basic shape is:

1
2
3
local function verify(t, actual)
  t:IsEqual("selected", actual.decision)
end

Inside a verification function for the first-test guide:

1
2
3
4
5
local function verify(t, actual)
  t:IsEqual("ops", t.input.request.requestingName)
  t:IsEqual("alice", t.environment.accounts[1].name)
  t:IsEqual("mapped-alice", actual.environment.user)
end

The three names are deliberately different: requested name, assumed account, and selected SSH target user.

Reading values

Use field access for objects and 1-based indexing or # for lists. Reading a missing named field is an error; it does not turn into a guessed value. There is no generic iteration over these read-only views. See Data value for data types and null/omission rules.