vtest

package
v1.8.0 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2026 License: MIT Imports: 16 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package vtest provides reusable, table-driven test helpers shared by the secret verifier packages.

It is placed under internal/verifier/internal so it can only be imported by verifier packages. The helpers exercise the failure paths that every HTTP verifier must handle safely:

  • a transport error (the server is closed) must yield StatusVerifyError;
  • a cancelled context must yield StatusVerifyError and NEVER StatusVerifiedInactive (a network failure is not evidence the secret is inactive);
  • a 200 response with a malformed JSON body must yield a defined status (the project standardizes this to StatusVerifyError).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(t *testing.T, c Case)

Run executes the shared safety suite against the verifier produced by c.New.

It does not contact any real service: a closed httptest server is used for the transport-error and cancellation cases, and a live httptest server that returns 200 with a non-JSON body is used for the malformed-body case.

Types

type Case

type Case struct {
	// Name is the verifier name, used as the subtest prefix.
	Name string

	// New builds the verifier under test.
	New Factory

	// Raw is a representative finding to verify. Its Raw value should be a
	// plausibly formatted secret so the verifier reaches the HTTP call.
	Raw detector.RawFinding

	// RawForURL optionally builds the finding after the hermetic endpoint is
	// known. It is used by credentials whose request destination is the finding
	// itself, such as provider webhook URLs.
	RawForURL func(string) detector.RawFinding

	// AdditionalSensitive lists credential-bearing representations that the
	// verifier derives outside Raw/RawV2 and must redact from results and logs.
	AdditionalSensitive [][]byte

	// MalformedStatus is the status the verifier returns for a 200 response
	// whose body is not valid JSON. Defaults to StatusVerifyError when zero
	// (the project standard). Set explicitly for verifiers that only inspect
	// the status code and do not decode a body.
	MalformedStatus finding.VerificationStatus

	// SkipMalformed skips the malformed-body case for verifiers that never
	// decode a response body on success.
	SkipMalformed bool
}

Case configures the shared verifier suite for one verifier package.

type Factory

type Factory func(apiURL string, client *http.Client) verifier.Verifier

Factory builds a verifier under test, wired to the given base URL and HTTP client. Both the URL and the client originate from a test server so that no real network call is made.

Jump to

Keyboard shortcuts

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