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

forge

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 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 List added in v0.1.2

func List(t testing.TB, w http.ResponseWriter, r *http.Request, next http.Handler, edit func(*Listed))

List answers r, a box's list, with each page it answers edited first, and any other request as next does: an operator's own list, a from beside each entry among what it can write.

func Lists added in v0.1.2

func Lists(t testing.TB, s *fakeserver.Server, edit func(*Listed))

Lists has s answer every list with it edited first (List).

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 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 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

type Listed added in v0.1.3

type Listed struct {
	Count      int64         `json:"count"`
	Messages   []ListedEntry `json:"messages"`
	NextCursor *string       `json:"next_cursor"`
}

Listed is a list as an operator writes it: the members PROTOCOL.md §11.11 gives one, and a from beside each entry, which it gives none and a reader ignores, as it does every member it does not know (§3.3).

type ListedEntry added in v0.1.3

type ListedEntry struct {
	protocol.MessageInfo
	From any `json:"from,omitempty"`
}

ListedEntry is one entry of a Listed: its members, and a from of any value, written only when it is set.

Jump to

Keyboard shortcuts

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