testtarget

package
v2.1.1 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package testtarget provides a deterministic mock HTTP target for ffuf integration tests. It models the response dimensions ffuf matches and filters on (status code, body size, word count, line count, latency, reflection, soft-404 baselines, redirects, request-gated endpoints, and a nested directory tree for recursion) and records every request it receives.

The server is hermetic: it binds to an ephemeral localhost port via httptest, uses no randomness, and returns byte-identical responses for identical requests. That determinism is what lets integration tests assert on exact result sets. Point the real ffuf http runner at Target.URL and only the target and the output sink are test doubles; the engine, runner, matchers and filters are the real ones.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Recorded

type Recorded struct {
	Method string
	Path   string
	Query  string
	Header http.Header
	Body   string
	At     time.Time
}

Recorded is one request the target received, exposed via Target.Requests so a test can assert on what ffuf actually sent (method, headers, body, timing).

type Target

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

Target wraps an httptest.Server with a thread-safe request recorder.

func New

func New() *Target

New starts a new deterministic target server. The caller must Close it.

func (*Target) Count

func (t *Target) Count() int

Count returns how many requests the target has received.

func (*Target) Requests

func (t *Target) Requests() []Recorded

Requests returns a snapshot copy of every request received so far.

Jump to

Keyboard shortcuts

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