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 ¶
- type Fake
- func (f *Fake) AddCredential(c cliproxyapi.Credential)
- func (f *Fake) Calls(path string) int
- func (f *Fake) ConfigPatches() []json.RawMessage
- func (f *Fake) Credential(name string) (c cliproxyapi.Credential, prefix string, ok bool)
- func (f *Fake) FailLogin(state, msg string)
- func (f *Fake) FinishLogin(state string, c cliproxyapi.Credential)
- func (f *Fake) Forget()
- func (f *Fake) LastCallback() (state, redirectURL string)
- func (f *Fake) SetModels(name string, models ...string)
- func (f *Fake) SetToken(name, token string)
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 ¶
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 ¶
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) 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 ¶
LastCallback returns the state and redirect address of the last accepted callback.