storetest

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 8, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package storetest is test support only, never imported by production code: it seeds a disposable gateway database whose confirmed revision is a given policy, optionally with a provisional revision and its deadline and an administrator, reads single values back for assertions, and builds the small test policies the seeds use. Unit tests of the packages that open a deployment use it instead of the operator's install command.

Index

Constants

View Source
const AnyObject = `{"type":"object","additionalProperties":true}`

AnyObject is a body schema that accepts any JSON object.

Variables

This section is empty.

Functions

func Int

func Int(t testing.TB, path, query string) int

Int reads the single integer that query returns from the database at path.

func JSONBody

func JSONBody(maxBytes int64, schema string) *policy.BodyRule

JSONBody is a body rule of at most maxBytes checked against schema.

func Policy

func Policy(withB bool) policy.Policy

Policy routes API a to upstream A and, withB, API b to upstream B, with the operations read-a, write-a, denied and (withB) read-b; the upstream addresses are never dialled.

func Protected

func Protected() policy.Policy

Protected is Policy(true) with authentication on every allowed operation and the roles READER and WRITER.

func Rate

func Rate(count, windowSeconds int64) *policy.RateRule

Rate is a per-account sliding-window rule of count requests per window.

func Seed

func Seed(t testing.TB, path string, p policy.Policy, opts Options)

Seed creates the database at path in normal mode, at the current schema version, with p as its confirmed revision 1.

Types

type Options

type Options struct {
	Provisional   *policy.Policy
	Deadline      time.Time
	Administrator string
}

Options adds a provisional revision 2, made from candidate 1, whose deadline is Deadline (nil Provisional: only the confirmed base), and an active administrator named Administrator with every permission and no usable password (empty: none).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL