testing/auth_apps.ts

Auth test app factories for adversarial testing.

Creates Hono test apps at each auth level (public, authenticated, keeper, per-role) for use in adversarial auth enforcement and input validation tests.

Declarations
#

6 declarations

view source

AuthTestApps
#

testing/auth_apps.ts view source

AuthTestApps

Pre-built Hono apps for each auth level, shared across adversarial test suites.

public

type Hono

authed

type Hono

keeper

type Hono

by_role

type Map<string, Hono>

create_auth_test_apps
#

testing/auth_apps.ts view source

(route_specs: RouteSpec[], roles: string[]): AuthTestApps

Create one Hono test app per auth level.

route_specs

the route specs to register

type RouteSpec[]

roles

all roles in the app

type string[]

returns

AuthTestApps

apps keyed by auth level

create_test_app_from_specs
#

testing/auth_apps.ts view source

(route_specs: RouteSpec[], auth_ctx?: RequestContext | undefined, credential_type?: "session" | "api_token" | "daemon_token" | undefined): Hono<BlankEnv, BlankSchema, "/">

Create a Hono test app from route specs with optional auth context.

route_specs

the route specs to register

type RouteSpec[]

auth_ctx?

optional request context to inject via middleware

type RequestContext | undefined
optional

credential_type?

optional credential type (default: 'session' when auth_ctx provided)

type "session" | "api_token" | "daemon_token" | undefined
optional

returns

Hono<BlankEnv, BlankSchema, "/">

a configured Hono app

create_test_request_context
#

testing/auth_apps.ts view source

(role?: string | undefined): RequestContext

Create a mock request context with optional role permit.

role?

optional role to grant

type string | undefined
optional

returns

RequestContext

resolve_test_path
#

testing/auth_apps.ts view source

(path: string): string

Replace Hono route params (:foo) with dummy values for HTTP testing.

path

type string

returns

string

select_auth_app
#

testing/auth_apps.ts view source

(apps: AuthTestApps, auth: RouteAuth): Hono<BlankEnv, BlankSchema, "/">

Select the Hono test app with correct auth for a route.

apps

the pre-built auth test apps

auth

the route's auth options

returns

Hono<BlankEnv, BlankSchema, "/">

the correctly-authenticated Hono app

Depends on
#

Imported by
#