wpsigntest

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2026 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Overview

Package wpsigntest is a test-only signer that mirrors Woodpecker's RFC-9421 extension-request signature [WP§8] so internal/wpsign.Verify can be exercised against a faithful, byte-compatible signature without a real Woodpecker server. It is imported by tests only; it is not part of ironbark's runtime.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Sign

func Sign(req *http.Request, body []byte, key ed25519.PrivateKey) error

Sign signs req exactly as Woodpecker's server does: an Ed25519 signer built from httpsign.NewSignConfig() (default-signed "created", no nonce/expires) over "@request-target" and "content-digest", with Content-Digest auto-generated from body [WP§8].

func SignOpts

func SignOpts(req *http.Request, body []byte, key ed25519.PrivateKey, o Opts) error

SignOpts is Sign with optional deviations; see Opts.

Types

type Opts

type Opts struct {
	// OmitCreated disables the signed "created" parameter entirely.
	OmitCreated bool
	// Components, if non-nil, overrides the set of covered components
	// (default: @request-target, content-digest).
	Components []string
	// TamperBodyAfterSign, if non-nil, replaces the request body (and
	// ContentLength) with this content AFTER signing, so any Content-Digest
	// that was signed no longer matches.
	TamperBodyAfterSign []byte
	// OmitDigestHeader removes the Content-Digest header AFTER signing,
	// even though it was covered by the signature.
	OmitDigestHeader bool
}

Opts controls deliberate deviations from a faithful Woodpecker signature, for exercising wpsign.Verify's failure taxonomy. The zero value produces no deviation; use Sign for the faithful case.

There is deliberately no way to forge the "created" timestamp: this harness only ever emits real, validly-signed requests (created = actual signing time). Task 5's stale/future-created matrix cases are exercised by advancing the *verifier's* injected `now` (wpsign.Verify's `now func() time.Time` parameter), not by forging the signer's clock.

Jump to

Keyboard shortcuts

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