feedtest

package
v0.5.8 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2026 License: GPL-3.0 Imports: 20 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 feedtest is an in-process PeerFeed Object (peer worker src/feed.ts) for the host side's tests: the hello check against a source secret and reader tokens, the fan-out of a source's records to every viewer with its ack, the replay request a viewer's connect sends every source with its key, the frames addressed to one viewer, and the signed config at /feed/<party id>/config — verified as the worker verifies it, the card under the party id and the body under the card's current identity key.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrCard is a missing X-Peer-Card, one that does not decode, or a card
	// the party id did not sign.
	ErrCard = errors.New("X-Peer-Card is not this party's root-signed card")
	// ErrSignature is a signature the card's current identity key did not make.
	ErrSignature = errors.New("X-Peer-Signature is not the card's identity key's signature")
)

Errors Verify returns, matched by the worker's codes.

Functions

func Hash

func Hash(secret string) string

Hash is a secret or token as the Object stores it.

func Verify

func Verify(party, cardHdr, sig string, msg []byte) error

Verify is the check the worker makes on a config request: cardHdr (X-Peer-Card: base64url of signature ‖ card bytes) is party's root-signed card, and sig (X-Peer-Signature, base64url) is the XEdDSA signature of msg by the card's current identity key — the first key with no until. A signature by the root key, by another identity key, or under another party's card is refused.

Types

type Frame

type Frame struct {
	Host string
	Body json.RawMessage
}

Frame is one frame a source sent, as the Object saw it.

type Held

type Held struct {
	V       int      `json:"v"`
	Party   string   `json:"party"`
	At      string   `json:"at"`
	Source  string   `json:"source"`
	Readers []string `json:"readers"`
}

Held is the config the Object holds, as GET answers it.

type Server

type Server struct {
	*httptest.Server
	// contains filtered or unexported fields
}

Server is one party's fake feed.

func Start

func Start(t testing.TB, party, secret string, tokens ...string) *Server

Start serves a feed for party, over TLS as the worker is; Client() is the client that trusts it. A secret seeds the config as a PUT would — the source secret and the reader tokens admitted — so a test needs no setup; "" starts with no config, as a party's feed is before peer feed setup.

func (*Server) CloseSources

func (s *Server) CloseSources()

CloseSources closes every source socket with 1001, as a deploy does.

func (*Server) Config

func (s *Server) Config() *Held

Config is the config held, nil before the first PUT.

func (*Server) Connect

func (s *Server) Connect(ctx context.Context, token, key string) (*Viewer, json.RawMessage, error)

Connect opens a viewer with token and, when key is not "", the reader key its page holds; the hello's answer is returned.

func (*Server) Frames

func (s *Server) Frames() []Frame

Frames is every frame the sources sent so far.

func (*Server) NoAck

func (s *Server) NoAck(off bool)

NoAck makes the Object take records without acking them, or acks again.

func (*Server) Puts

func (s *Server) Puts() int

Puts is how many configs were taken.

func (*Server) Refused

func (s *Server) Refused() int

Refused is how many hellos were closed 4401.

func (*Server) ServeHTTP

func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (*Server) Sources

func (s *Server) Sources() int

Sources is how many source sockets are open.

type Viewer

type Viewer struct {
	Frames chan json.RawMessage
	// contains filtered or unexported fields
}

Viewer is a connected reader page: the frames it received come on Frames.

func (*Viewer) Close

func (v *Viewer) Close()

Close ends the viewer.

Jump to

Keyboard shortcuts

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