cliproxyapitest

package
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2026 License: Apache-2.0 Imports: 14 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 cliproxyapitest is an in-memory fake of the OAuth engine's v8 management API for tests. It serves the routes remora's client uses with the engine's status codes, messages and body shapes (checked against the real engine by the contract test in package cliproxyapi), and hooks for driving logins from a test.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Fake

type Fake struct {
	URL string
	// contains filtered or unexported fields
}

Fake is a running fake engine. URL is its base address (without the management prefix).

func NewServer

func NewServer(t *testing.T, secret string) *Fake

NewServer starts a fake that accepts the management secret and stops it when the test ends.

func (*Fake) AddCredential

func (f *Fake) AddCredential(c cliproxyapi.Credential)

AddCredential adds or replaces a credential by c.Name. An empty ID becomes the name, an empty AuthIndex a fresh one, an empty Status "active" (or "disabled" when Disabled), an empty Label the email or else the provider.

func (*Fake) Calls

func (f *Fake) Calls(path string) int

Calls counts the requests that reached a route, by path below the management prefix (for example "/credentials/refresh"), whatever their outcome.

func (*Fake) ConfigPatches

func (f *Fake) ConfigPatches() []json.RawMessage

ConfigPatches returns the bodies of the accepted PATCH /config calls, in order.

func (*Fake) Credential

func (f *Fake) Credential(name string) (c cliproxyapi.Credential, prefix string, ok bool)

Credential returns a credential and its prefix.

func (*Fake) FailLogin

func (f *Fake) FailLogin(state, msg string)

FailLogin fails a login with msg as its status error.

func (*Fake) FinishLogin

func (f *Fake) FinishLogin(state string, c cliproxyapi.Credential)

FinishLogin completes a login: its status becomes "ok" and c appears among the credentials.

func (*Fake) Forget

func (f *Fake) Forget()

Forget drops every login session, as an engine restart does.

func (*Fake) LastCallback

func (f *Fake) LastCallback() (state, redirectURL string)

LastCallback returns the state and redirect address of the last accepted callback.

func (*Fake) SetModels

func (f *Fake) SetModels(name string, models ...string)

SetModels sets the models a credential serves.

func (*Fake) SetToken added in v0.3.0

func (f *Fake) SetToken(name, token string)

SetToken sets what "$TOKEN$" becomes in an api-call as the named credential; the default is "tok-" + its auth index.

Jump to

Keyboard shortcuts

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