fakeapi

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package fakeapi is a token-authenticated HTTPS API for tests: a stand-in for a provider such as a CDN or analytics service.

Index

Constants

View Source
const (
	Good      = "fake-good-token"
	NoScope   = "fake-noscope-token"
	Limited   = "fake-limited-token"
	Broken    = "fake-broken-token"
	NotJSON   = "fake-notjson-token"
	AccountID = "acct-1"
	Label     = "Acme Production"
)

Tokens with fixed behaviour. Any other token is rejected with 401.

Variables

This section is empty.

Functions

This section is empty.

Types

type API

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

API is a running fake API.

func Start

func Start(t testing.TB) *API

Start starts the API and stops it when the test ends.

func (*API) Manifest

func (a *API) Manifest() provider.Manifest

Manifest returns a manifest whose base URL is the API.

func (*API) Provider

func (a *API) Provider(t testing.TB) *apikey.Provider

Provider returns an apikey provider for the API.

func (*API) Restore

func (a *API) Restore(tok string)

Restore makes a revoked token valid again.

func (*API) Revoke

func (a *API) Revoke(tok string)

Revoke makes a token invalid from now on; Restore undoes it.

func (*API) Seen

func (a *API) Seen() []string

Seen returns the Authorization headers received on /data.

Jump to

Keyboard shortcuts

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