Documentation
¶
Overview ¶
Package webhooktest provides a sign↔verify conformance suite for webhook.Signer and webhook.Verifier implementations. It is intended for _test.go use only; production code must not import this package.
kernel/ layering rule: non-_test.go files in kernel/ must not import testify or kernel/clock/clockmock. This package uses stdlib testing.T helpers only and accepts a VerifierFactory to avoid importing clockmock directly.
Usage — wire in the package-level conformance call:
func TestSignerVerifierConformance(t *testing.T) {
webhooktest.RunSignerVerifierConformance(t,
webhook.NewHMACSigner,
func(ts time.Time) (webhook.Verifier, error) {
return webhook.NewHMACVerifier(clockmock.New(ts))
},
)
}
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RunSignerVerifierConformance ¶
func RunSignerVerifierConformance( t *testing.T, newSigner func(webhook.Source) (webhook.Signer, error), newVerifier VerifierFactory, )
RunSignerVerifierConformance runs the sign↔verify behavioral contract suite.
newSigner is a factory bound to a given Source. newVerifier is a factory that pins the verifier's clock to the given time.
Sub-cases:
- round_trip: sign produces Headers that verify passes.
- tamper_body: altering the body after signing → ErrWebhookInvalidSignature.
- tamper_signature: corrupted signature token → ErrWebhookInvalidSignature.
- tamper_timestamp_expired: out-of-window timestamp → ErrWebhookTimestampExpired.
- multi_token_rotation_first_matches: first valid token in multi-token header accepted.
- multi_token_rotation_second_matches: last token in multi-token header also accepted.
- timestamp_outside_window: bidirectional tolerance check.
- empty_secret_source_rejected_by_signer: zero-value Source → ErrWebhookConfigInvalid.
- no_matching_token: two non-matching tokens → ErrWebhookInvalidSignature.
Types ¶
type VerifierFactory ¶
VerifierFactory creates a webhook.Verifier whose internal clock is pinned to ts. The caller provides the factory so conformance.go does not import kernel/clock/clockmock (kernel-isolation rule prohibits clockmock in non-_test.go kernel files).