testenv

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2026 License: Apache-2.0 Imports: 36 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package testenv runs an in-process Inkless with a throwaway database, dev keys, a local TSA and a capturing mailer, plus a scripted browser for the ceremony. For tests and examples only.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Conformance

func Conformance(t *testing.T, driverName string)

Conformance runs the storage conformance suite against driver, skipping when its server URL is not configured.

func Database

func Database(ctx context.Context, driverName string) (dbURL string, cleanup func(), err error)

Database creates an empty database for driver and returns its URL and a cleanup func.

func Drivers

func Drivers() []string

Drivers returns the drivers to test: sqlite always, postgres and mysql when INKLESS_TEST_POSTGRES_URL or INKLESS_TEST_MYSQL_URL is set (a user that may create databases).

Types

type Browser

type Browser struct {
	// Base is the server's base URL.
	Base string
	// contains filtered or unexported fields
}

Browser drives the hosted ceremony like a user agent with cookies. It does not follow redirects, so outcomes can be inspected.

func NewBrowser

func NewBrowser(base string) *Browser

NewBrowser returns a Browser with an empty cookie jar for the server at base.

func (*Browser) Decline

func (b *Browser) Decline(reason string) (*Response, error)

Decline declines on the current review page with the given reason. Like Sign, it resolves Location to the link back to the application.

func (*Browser) Get

func (b *Browser) Get(u string) (*Response, error)

Get loads a URL (absolute, or a path on Base).

func (*Browser) Open

func (b *Browser) Open(link string) (*Response, error)

Open loads a signing link like a user who presses its start button: the link page asks first, and only the form post consumes the link. It returns the response that carries the session cookie, or the link page itself when the link cannot be opened.

func (*Browser) Page

func (b *Browser) Page() string

Page is the last HTML page loaded.

func (*Browser) Post

func (b *Browser) Post(path string, fields url.Values) (*Response, error)

Post submits a form on the current page, adding its nonce and document digest unless fields sets them.

func (*Browser) Ready

func (b *Browser) Ready(link string, m *Mailer, email string) (*Response, error)

Ready opens a session link, requests a code, enters it and loads the review page. It returns the review page response.

func (*Browser) Sign

func (b *Browser) Sign() (*Response, error)

Sign ticks consent and signs on the current review page. The signed page links back to the application; on success the returned Location is that link, as if the signer had followed it.

type Clock

type Clock struct {
	// contains filtered or unexported fields
}

Clock is real time plus an offset that tests advance.

func (*Clock) Advance

func (c *Clock) Advance(d time.Duration)

Advance moves the clock forward by d.

func (*Clock) Now

func (c *Clock) Now() time.Time

Now returns the current time moved forward by the total Advance.

type Env

type Env struct {
	// URL is the server's base URL.
	URL string
	// Service is the running service, for direct calls and ticking jobs.
	Service *service.Service
	// Mailer captures the codes the service emails.
	Mailer *Mailer
	// Keys are the signing and trust keys the service uses.
	Keys *signer.Keys
	// Store is the open database.
	Store storage.Store
	// Clock is the service's clock. Advance it to move time forward
	// without waiting.
	Clock *Clock
	// contains filtered or unexported fields
}

Env is a running in-process Inkless.

func Start

func Start(ctx context.Context, dbURL string) (*Env, error)

Start runs Inkless against dbURL with fresh development keys. Background jobs run every 50ms.

func StartWith

func StartWith(ctx context.Context, dbURL string, keys *signer.Keys, tsa devpki.Cert) (*Env, error)

StartWith runs Inkless against dbURL with keys and a local TSA issuing tokens with tsa.

func (*Env) Close

func (e *Env) Close()

Close stops the server and background jobs and closes the store.

func (*Env) Complete

func (e *Env) Complete(ctx context.Context) (final, pkg []byte, err error)

Complete runs one single-signer request to completion and returns its sealed PDF and evidence package.

func (*Env) VerifyOptions

func (e *Env) VerifyOptions() verify.Options

VerifyOptions returns the trust configuration matching the env's keys.

type Mailer

type Mailer struct {
	// contains filtered or unexported fields
}

Mailer captures messages instead of sending them, unless UseMailpit was called.

func (*Mailer) LastCode

func (m *Mailer) LastCode(addr string) string

LastCode returns the most recent code mailed to addr, or "" if there is none.

func (*Mailer) Send

func (m *Mailer) Send(ctx context.Context, msg mail.Message) error

Send records msg, or delivers it through the Mailpit relay.

func (*Mailer) UseMailpit

func (m *Mailer) UseMailpit(relay mail.Mailer, api string)

UseMailpit makes the mailer deliver through relay and read codes back from the Mailpit API at api.

type Response

type Response struct {
	// Status is the HTTP status code.
	Status int
	// Location is the Location header, set on redirects.
	Location string
	// Body is the response body.
	Body string
}

Response is a page or redirect.

Jump to

Keyboard shortcuts

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