OAuthTestHelper (anubis_mcp v1.6.0)

Copy Markdown

Helpers for testing OAuth 2.1 authorization in Anubis servers.

Provides token building, mock validator construction, and fixtures for Bypass-based HTTP endpoint mocking.

Summary

Functions

Returns a mock introspection response body for an active token.

Builds a minimal authorization config map (as if parsed by Authorization.parse_config!/1).

Builds a normalized claims map suitable for injecting into Context.auth.

Returns an inactive introspection response body.

Returns the introspection endpoint URL for a Bypass instance.

Configures a Bypass instance to serve an introspection endpoint.

Functions

active_introspection_response(opts \\ [])

Returns a mock introspection response body for an active token.

auth_config(overrides \\ %{})

Builds a minimal authorization config map (as if parsed by Authorization.parse_config!/1).

claims(overrides \\ %{})

Builds a normalized claims map suitable for injecting into Context.auth.

Defaults to a non-expired token for resource with scopes ["tools:read"].

inactive_introspection_response()

Returns an inactive introspection response body.

introspection_url(bypass)

Returns the introspection endpoint URL for a Bypass instance.

setup_introspection_bypass(bypass, opts \\ [])

Configures a Bypass instance to serve an introspection endpoint.

The respond option controls what the endpoint returns:

  • :active — returns an active token response (default)
  • :inactive — returns an inactive token response
  • {:error, status} — returns an error HTTP status