scenario

package
v0.229.0 Latest Latest
Warning

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

Go to latest
Published: May 27, 2026 License: MIT Imports: 30 Imported by: 0

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

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
	BearerTok string
	MFAToken  string // captured from a 403 mfa_required response.
	LastResp  *http.Response
	LastBody  []byte
	// 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) Do

func (c *Context) Do(method, path string, body string, withBearer bool)

Do sends an HTTP request and stores the response on the context.

func (*Context) DoForm

func (c *Context) DoForm(method, path string, form url.Values, withBearer bool)

DoForm sends a POST with application/x-www-form-urlencoded body.

func (*Context) MintBearer

func (c *Context) MintBearer()

MintBearer issues a token via the live /oauth/token endpoint.

func (*Context) VerifyAccessTokenAgainstJWKS

func (c *Context) VerifyAccessTokenAgainstJWKS(tok string) error

VerifyAccessTokenAgainstJWKS fetches the mock's JWKS and verifies the token's RS256 signature using golang-jwt + MicahParks/keyfunc.

Jump to

Keyboard shortcuts

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