webhooktest

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package webhooktest provides deterministic clocks, nonces, identifiers, signers, and verifiers for consumer tests.

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidConfig = errors.New("webhooktest: invalid fixture configuration")

Functions

This section is empty.

Types

type Clock

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

Clock is a concurrency-safe manually controlled clock.

func NewClock

func NewClock(now time.Time) *Clock

NewClock constructs a clock at the supplied instant.

func (*Clock) Advance

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

Advance moves the controlled instant by duration.

func (*Clock) Now

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

Now returns the controlled instant.

func (*Clock) Set

func (c *Clock) Set(now time.Time)

Set replaces the controlled instant.

type Fixture

type Fixture struct {
	Clock    *Clock
	Signer   *webhook.Signer
	Verifier *webhook.Verifier
	// contains filtered or unexported fields
}

Fixture owns a shared clock, signer, verifier, and deterministic ID source.

func NewFixture

func NewFixture(config FixtureConfig) (*Fixture, error)

NewFixture constructs a deterministic pair without global state.

func (*Fixture) IDGenerator

func (f *Fixture) IDGenerator() (string, error)

IDGenerator returns the next deterministic identifier and matches the DeliveryConfig IDGenerator signature.

type FixtureConfig

type FixtureConfig struct {
	Algorithm   webhook.Algorithm
	KeyID       string
	Secret      []byte
	Time        time.Time
	Tolerance   time.Duration
	NoncePrefix string
	IDPrefix    string
}

FixtureConfig defines one deterministic signing and verification pair.

Jump to

Keyboard shortcuts

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