Help us shape the future of Go! Take the 2026 Go Developer Survey

forge

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package forge is how a test plays the hostile operator in front of internal/fakeserver: a read of a box served otherwise than the server holds it, mail put in a box as only the operator can, a call answered as a server that is down. The Go client's tests and the script's share it, so each forgery is written once, as an operator could make it.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Capture

func Capture(s *fakeserver.Server, method, suffix string) *[]byte

Capture records the body of the next request to s matching method and path suffix: JSON, or a send's ciphertext.

func Carry

Carry answers r as next answers it, but that a 410 revoked carries rec in place of the record its server holds, or none for nil: an operator that says an address is revoked and shows another record, or none.

func Encrypt

func Encrypt(t testing.TB, s *fakeserver.Server, to protocol.Address, parts ...[]byte) []byte

Encrypt encrypts the parts, one after the other, to a box's current prekey as s holds it.

func FailOnce

func FailOnce(s *fakeserver.Server, method, suffix string)

FailOnce answers the first request to s matching method and path suffix with a 503, as a server that is down would.

func Hides

func Hides(t testing.TB, s *fakeserver.Server)

Hides puts an operator in front of s that serves every box without what its identity signed about it: a revoked box as if it were not, and no revocation of a box's certificates.

func Line

func Line(t testing.TB, doc []byte, from, to protocol.Address, body string, at time.Time) []byte

Line is an envelope's line as a sender writes it: from the box whose identity document it carries, to a box, sent at at.

func ReadOf

func ReadOf(r *http.Request) (protocol.Address, bool)

ReadOf reports whether r is a read of a box, GET /v1/<address>, and of which box.

func Refuse

func Refuse(w http.ResponseWriter, code protocol.Code, with ...func(*protocol.Problem))

Refuse answers as the server refuses a call, with code under its own status and type; each of with sets a member it carries.

func Seal

func Seal(t testing.TB, s *fakeserver.Server, to, from protocol.Address, plaintext ...[]byte) string

Seal encrypts what a sender encrypts, an envelope's line and then whatever follows it, to a box's current prekey as s holds it, and stores it in that box as mail from a sender, as only the operator can. It returns the id it is stored under: the hash of the ciphertext.

func Serve

func Serve(t testing.TB, s *fakeserver.Server, w http.ResponseWriter, r *http.Request, next http.Handler, edit func(*protocol.BoxResponse))

Serve answers r, a read of a box, with the box s holds, edited first: an operator that serves a box otherwise than it holds it. A revoked box is served as it was before, from its last prekey, with none of what its identity signed about it, so edit can make it look like any box.

func Sign

func Sign(t testing.TB, s ssh.Signer, line []byte, to protocol.Address) []byte

Sign signs an envelope's line for a recipient, as the stock tools do.

Types

This section is empty.

Jump to

Keyboard shortcuts

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