Documentation
¶
Overview ¶
Package scenario holds the godog test harness: a per-scenario context that boots the auth0-mock service in-process on a random port and provides HTTP helpers for the .feature step files.
Index ¶
- func RegisterSteps(sc *godog.ScenarioContext, c *Context)
- type Context
- func (c *Context) DeleteSeedFile() error
- func (c *Context) Do(method, path string, body string, withBearer bool)
- func (c *Context) DoForm(method, path string, form url.Values, withBearer bool)
- func (c *Context) DoFormWithAuthorization(method, path string, form url.Values, authorization string)
- func (c *Context) KeepCookies()
- func (c *Context) MintBearer()
- func (c *Context) MintVia(host string)
- func (c *Context) ReplaceSeedFile(content string) error
- func (c *Context) RestartWithIssuer(issuer string)
- func (c *Context) RestartWithSeed(content string) error
- func (c *Context) VerifyAccessTokenAgainstJWKS(tok string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RegisterSteps ¶
func RegisterSteps(sc *godog.ScenarioContext, c *Context)
RegisterSteps wires the .feature step phrases to Go functions.
Types ¶
type Context ¶
type Context struct {
BaseURL string
Host string // when set, every request carries this Host header
BearerTok string
MFAToken string // captured from a 403 mfa_required response.
RefreshTok string // captured from a token response.
LastResp *http.Response
LastBody []byte
SavedBody []byte // set by "I save the response body".
// SavedValues holds JSON values saved by name with "I save the response
// JSON path".
SavedValues map[string]string
// SSEResp holds the response from a successful SSE subscription
// so subsequent steps (push, deliver) can read frames from its
// body without conflicting with assertions against LastResp.
SSEResp *http.Response
// contains filtered or unexported fields
}
Context is the per-scenario state passed to step definitions.
func New ¶
func New(t *testing.T, sc *godog.ScenarioContext) *Context
New constructs a fresh Context, boots the service in-process on a random localhost port, and registers cleanup hooks via godog.
func (*Context) DeleteSeedFile ¶ added in v0.234.0
DeleteSeedFile removes the seed file and polls once.
func (*Context) DoFormWithAuthorization ¶ added in v0.233.0
func (c *Context) DoFormWithAuthorization(method, path string, form url.Values, authorization string)
DoFormWithAuthorization is DoForm with an explicit Authorization header value; empty sends none.
func (*Context) KeepCookies ¶ added in v0.233.0
func (c *Context) KeepCookies()
KeepCookies makes this scenario's later requests share one cookie jar.
func (*Context) MintBearer ¶
func (c *Context) MintBearer()
MintBearer issues a token via the live /oauth/token endpoint.
func (*Context) MintVia ¶ added in v0.234.0
MintVia mints a user token through the live /oauth/token endpoint, sending the request with the given Host header, and stores it as the bearer. The whole token response is left in LastBody so its id_token can be reused.
func (*Context) ReplaceSeedFile ¶ added in v0.234.0
ReplaceSeedFile saves content over the seed file the way an editor does (write a temp file, rename it over) and reloads it. Nothing sleeps: the harness runs no watcher and polls twice instead, as a changed file is acted on only once it has been seen on two consecutive polls.
func (*Context) RestartWithIssuer ¶ added in v0.234.0
RestartWithIssuer stops the scenario's server and boots a fresh one on a new port with the given ISSUER_URL value (e.g. "auto"), repointing BaseURL.
func (*Context) RestartWithSeed ¶ added in v0.234.0
RestartWithSeed stops the scenario's server and boots a fresh one whose SEED_FILE holds content. A seed that fails to load is returned as the error and leaves no server running.
func (*Context) VerifyAccessTokenAgainstJWKS ¶
VerifyAccessTokenAgainstJWKS fetches the mock's JWKS and verifies the token's RS256 signature using golang-jwt + MicahParks/keyfunc.