Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ContextFile ¶
type ContextFile struct {
Path string `yaml:"path"`
}
ContextFile references an external JSON or YAML file for context.
type ContextValue ¶
ContextValue is an inline context key-value pair.
type Runner ¶
type Runner struct {
// contains filtered or unexported fields
}
Runner executes test cases. All relative paths are resolved against baseDir.
type SuiteResult ¶
type SuiteResult struct {
Results []TestResult
Passed int
Failed int
Errors int
Duration time.Duration
}
SuiteResult captures the outcome of an entire test suite.
type TestCase ¶
type TestCase struct {
Name string `yaml:"name"`
Policy string `yaml:"policy"`
Expect string `yaml:"expect"` // "PASS" or "FAIL"
Subject string `yaml:"subject"`
Attestations []string `yaml:"attestations"`
// Collectors lists attestation collector init strings (e.g.
// "fs:testdata/bundle"). Filesystem-backed collectors ("fs:") resolve
// their path relative to the test file's directory. Collectors are an
// alternative evidence source to Attestations and are required to test
// policies whose evidence must be synthesized (e.g. signature
// attestations built from bundles or detached signatures).
Collectors []string `yaml:"collectors"`
// Signers lists the accepted signer identities (identity slugs, e.g.
// "sigstore::<issuer>::<identity>") passed to the verifier, equivalent to
// the --signer flag. Required to exercise policies that gate on the signer.
Signers []string `yaml:"signers"`
Context []ContextValue `yaml:"context"`
ContextFiles []ContextFile `yaml:"context-files"`
// AmpelVersion is the minimum ampel version (semver, e.g. "v1.3.7") the
// test needs. Harnesses that run tests against several ampel versions
// skip the test on engines older than this (see RunsOn). Empty means the
// test runs on any version.
AmpelVersion string `yaml:"ampel-version"`
}
TestCase defines a single policy test.
func (*TestCase) RunsOn ¶ added in v0.1.1
RunsOn reports whether the test case can run on the given ampel version.
A test without an AmpelVersion floor runs on any engine. When the engine version is unknown or not a semantic version (e.g. a development build reporting "(devel)"), the test is assumed to run: a development tree is expected to carry every feature the tests target. Module pseudo-versions compare as semver, so a build of a commit between two tags sorts between them and one ahead of the latest tag sorts below the next tag, which skips rather than fails tests floored at that next release.
type TestResult ¶
type TestResult struct {
Name string
Expected string // "PASS" or "FAIL"
Actual string // "PASS", "FAIL", "SOFTFAIL", "ERROR"
Passed bool
Error error
Duration time.Duration
}
TestResult captures the outcome of a single test case.
type TestSuite ¶
type TestSuite struct {
Tests []TestCase `yaml:"tests"`
}
TestSuite holds all test cases loaded from a config file.
func LoadConfig ¶
LoadConfig reads, parses, and validates a test config file.