hrtest

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2026 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Overview

Package hrtest is a fake HostRepute (API and OAuth server) for tests. It answers with the demo data and checks what ReputeCast sends: the bearer token, the PKCE verifier, and that only domains and IPs are submitted.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Fake

type Fake struct {
	*httptest.Server

	// Token is the API key or access token the fake accepts.
	Token string
	// Monitored assets and the plan's limit (0 = unlimited).
	Monitored []string
	Limit     int
	// Down answers 503 to every call; Revoked answers 401.
	Down, Revoked bool
	// Alerts are returned by /alerts (the demo's when nil).
	Alerts []hostrepute.Alert
	// Revocations counts token revocations (disconnect).
	Revocations int
	// Requests logs "METHOD path" of every call.
	Requests []string
	// Bodies logs request bodies of POST calls.
	Bodies []string
	// contains filtered or unexported fields
}

Fake is a running fake HostRepute.

func New

func New(t testing.TB, token string) *Fake

New starts a fake HostRepute that accepts token.

func (*Fake) APIURL

func (f *Fake) APIURL() string

APIURL is the API base to configure (…/v1).

func (*Fake) Consent

func (f *Fake) Consent(t testing.TB, authorizeURL string) (code, state string)

Consent plays the consent page: it reads the authorize URL ReputeCast produced and returns the code HostRepute would send back, plus the state.

Jump to

Keyboard shortcuts

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