Documentation
¶
Overview ¶
Package hubtest is a fake lockhub for the tests of locks: it speaks the lock API v1 (signed requests, tickets, decisions with a cursor) on an httptest server, and lets a test decide tickets.
Index ¶
- type Hub
- func (h *Hub) Answer(id string) []byte
- func (h *Hub) Close()
- func (h *Hub) Consumed(id string) bool
- func (h *Hub) Decide(id string, out ticket.Outcome, reason string)
- func (h *Hub) DecideWith(id string, out ticket.Outcome, reason string, key ed25519.PrivateKey, ...)
- func (h *Hub) Pushed() int
- func (h *Hub) RawRequest(id string, raw []byte)
- func (h *Hub) Request(id string, kind ticket.RequestKind, rk *ticket.RevealKey, ...) string
- func (h *Hub) Requeue(id string)
- func (h *Hub) SetLockKey(pub ed25519.PublicKey)
- func (h *Hub) SetPushStatus(code int)
- func (h *Hub) SetWithdrawStatus(id string, code int)
- func (h *Hub) Sinces() []string
- func (h *Hub) Ticket(id string) []byte
- func (h *Hub) Tickets() []string
- func (h *Hub) URL() string
- func (h *Hub) Withdrawn(id string) (string, bool)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Hub ¶
type Hub struct {
// Pub and Priv are the hub's key; a lock pins Pub.
Pub ed25519.PublicKey
Priv ed25519.PrivateKey
// contains filtered or unexported fields
}
Hub is a fake lockhub serving one lock instance.
func (*Hub) Answer ¶ added in v0.5.0
Answer is the lock's answer to request id, nil before it answered.
func (*Hub) DecideWith ¶
func (h *Hub) DecideWith(id string, out ticket.Outcome, reason string, key ed25519.PrivateKey, mod func(*ticket.Decision))
DecideWith is Decide signed with key (nil: the hub's), mod applied to the decision before signing (nil: none).
func (*Hub) RawRequest ¶ added in v0.5.0
RawRequest queues raw as a hub request under id, as it is (forged or malformed requests).
func (*Hub) Request ¶ added in v0.5.0
func (h *Hub) Request(id string, kind ticket.RequestKind, rk *ticket.RevealKey, mod func(*ticket.HubRequest)) string
Request queues a hub request about ticket id, signed with the hub's key after mod (nil: none), for the lock's next poll, and returns its id. A reveal carries rk.
func (*Hub) Requeue ¶ added in v0.5.0
Requeue queues request id again, as it was first sent (a replay).
func (*Hub) SetLockKey ¶
SetLockKey changes the lock key the hub pinned for the instance.
func (*Hub) SetPushStatus ¶
SetPushStatus makes every POST /v1/tickets answer code (0: normal).
func (*Hub) SetWithdrawStatus ¶ added in v0.4.0
SetWithdrawStatus makes a withdrawal of ticket id answer code (0: the normal 204, recorded).